如何在kendo图表中显示各个字段的数据点?

时间:2014-04-25 15:27:53

标签: kendo-ui kendo-datasource kendo-chart

我想在工具提示中显示所有数据点。 我的数据有2个系列, 一系列有2分, 一个点有3个字段(值,基数和日期)

我试试这个http://trykendoui.telerik.com/OCeB,但重复了x轴

如果有解决方案我想使用datasource

1 个答案:

答案 0 :(得分:0)

通常系列中的x值不应重复,您有两个选项 修复你的图表:

选项1: 在每个数据点上定义两个系列的值

        var internetUsers = [
        {
          "S1Value" : 1,
          "S1base" : 2,
          "S2Value" : 3,
          "S2base" : 2,
          "date" : 2011
        },
        {
          "S1Value" : 5,
          "S1base" : 6,
          "S2Value" : 4,
          "S2base" : 7,              
          "date" : 2013
        },
      ]

并为每个工具提示定义:

           series: [{
                field: "S1Value",
                name: "United States", 
                tooltip: {
                  visible: true,
                  background: "#FFFFFF",
                  template:
                    "#= series.name # <br /> " +
                        "Fecha = #= category # <br /> " +
                        "Valor = #= value # <br/> " +
                        "Base = #= dataItem.S1base # ",
                  format: "n2",
            }
            },{
                field: "S2Value",
                name: "Mexico", 
                  tooltip: {
                  visible: true,
                  background: "#FFFFFF",
                  template:
                    "#= series.name # <br /> " +
                        "Fecha = #= category # <br /> " +
                        "Valor = #= value # <br/> " +
                        "Base = #= dataItem.S1base # ",
                  format: "n2",
            }
            }

http://trykendoui.telerik.com/OCeB/2

选项2:

将您的系列分成两部分:

        var internetUsersS1 = [
        {
          "S1" : 1,
          "base" : 2,
          "date" : 2011
        },
        {
          "S1" : 5,
          "base" : 6,
          "date" : 2013
        }
      ]
      var internetUsersS2 = [
          {
          "S2" : 3,
          "base" : 2,
          "date" : 2011


        },
          {
          "S2" : 4,
          "base" : 7,
          "date" : 2013
        }
      ]

...现在为每个系列提供自己的数据源:

 series: [{
                data: internetUsersS1,
                field: "S1",
                name: "United States"
            },{
                data: internetUsersS2,
                field: "S2",
                name: "Mexico"
            }
            ]

http://trykendoui.telerik.com/OCeB/3