Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/461.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何在剑道ui中动态设置图例系列_Javascript_Html_Kendo Ui - Fatal编程技术网

Javascript 如何在剑道ui中动态设置图例系列

Javascript 如何在剑道ui中动态设置图例系列,javascript,html,kendo-ui,Javascript,Html,Kendo Ui,如何设置具有不同值的相同字段名的序列。以便可以使用不同的值显示图例 我曾以这种方式尝试代码: $(document).ready(function(){ var db = new kendo.data.DataSource({ data: data, group: { field: "studentmarks" } }); db.read(); $("#Chart").kendoChart({ theme: $

如何设置具有不同值的相同字段名的序列。以便可以使用不同的值显示图例

我曾以这种方式尝试代码:

  $(document).ready(function(){
  var db = new kendo.data.DataSource({
      data: data,
      group: {
          field: "studentmarks"
      }

  });

  db.read();

  $("#Chart").kendoChart({
  theme: $(document).data("kendoSkin") || "silver",
  dataSource: db,
  aggregate: [{ field: "studentmarks", aggregate: "sum"}],
          group: { field: "studentsmarks" },

    title: {
        text: "Studentdetails"
    },
    dateField: "time",
    legend: {
        position: "bottom"
    },
    chartArea: {
        background: ""
    },
    seriesDefaults: {
        type: "line",field:"ID"
    },
    series: [{
        name: "marks",
        data: data,
        filter: "studentmarks",
        color: "#FC0505",
        width: 2,
        visibleInLegend: "studentmarks",

        markers: {
            visible: false
        },
        tooltip: {
            visible: true,
            format: "{0}%"
        }
    }, {
        name: "ID",
        filter: "studentmarks",
        data: data,
         axis: "",
        color: "#2605FC",
        width: 2,

        markers: {
            visible: true
        },
        tooltip: {
            visible: true,
            format: "{0}"
        }
    }, {
        name: "phone",
        filter: "studentmarks",
        data: data,
         axis: "",
        color: "#ED9AA5",
        width: 2,

        markers: {
            visible: true
        },
        tooltip: {
            visible: true,
            format: "{0}%"
        }

    },
     {
         name: "cbs",
        filter:"studentmarks",
        data: data,
         axis: "",
         color: "#9AA5ED",
        visible: true,
        opacity: .4,
        width: 2,

        markers: {
            visible: true
        },
        tooltip: {
            visible: true,
            format: "{0}%"
        }
    }],
    valueAxis: [{
        title: { text: "" },
        name: "ID",
            majorUnit: 0.5,
            max: 5.0,
            min: 0
    }, {
        name: "ink",
        title: { text: "" },
        min: 0,
        max: 6727.14,
        majorUnit: 1000,
        minorUnit: 500
    }],


      navigator: {
            series: {
                type: "area",
                color: "red",
                field: "studentmarks",
                //stack: "true",
                //value:"",
                data: data,
                aggregate: "min",
                name: "sai",
                select: {
                    from: "2009-01-01 17:08:04",
                    to: "2013-12-24 20:30:26"
                },
                //labels: { color: "green", visible: false },
                tooltip: { background: "green", format: "{0}", color: "white", visible: true }
            }
        }
});

});

也许这会有帮助

var checkCookie=function(){
var chartData1=[{
姓名:“汉斯”,
颜色:“黑色”,
数据:[1,2,3,4,5]
}]
var chartData2=[{
姓名:“汉斯”,
颜色:“黑色”,
数据:[1,2,3,4,5]
}, {
姓名:“弗兰兹”,
颜色:“红色”,
数据:[6,7,8,9,10]
}]
如果(此处){
返回图表数据1
}否则{
返回图表数据2
}
}
$(“#图表”)。肯多卡特({
主题:$(文档).data(“肯多斯金”)| |“默认值”,
图表区:{
背景:“,
身高:150
},
图例:{位置:“底部”},
系列默认值:{
键入:“列”,
斯塔克:没错,
覆盖:{渐变:“无”},
},
系列:checkCookie(),
... 
});
 var mydata=checkCookie();
$("#chart").kendoChart({
        theme: $(document).data("kendoSkin") || "default",
        chartArea: {
            background: "",
            height: 150
        },dataSource:{
    data:mydata,
     serverSorting: false,
    group: {
        field:"name",
    },sort: [{field: "name", dir: "asc"}, 

    schema:{
        model:{
            fields:{
                "name":{"type":"string"},
                "data":{"type":"number"}
            }
        }
    }
},
        legend: {position: "bottom"},

        series: [{type:"column", field:"data", stack:true,colorField: "color"}],