1

给定以下 JSON

{
   "ApprovalsSeries":{
      "Items":[
         {
            "Date":"2014-03-01T00:00:00",
            "Value":430
         },
         {
            "Date":"2014-03-02T00:00:00",
            "Value":173
         }
      ],
      "SeriesName":"Place Approvals"
   },
   "RequestsSeries":{
      "Items":[
         {
            "Date":"2014-03-01T00:00:00",
            "Value":143
         },
         {
            "Date":"2014-03-02T00:00:00",
            "Value":19
         }
      ],
      "SeriesName":"Place Requests"
   }
}

我正在尝试创建一个包含 2 个系列的简单条形图,以及一个使用日期的类别轴。但是我似乎无法管理它,并且在网上找不到任何绑定到复杂 json 数据的示例。

4

1 回答 1

1

想通了,下面是折线图,但概念和条形图是一样的。

        $("#approvalschart").kendoChart({
            title: {
                text: "Place Requests / Approvals by Date"
            },
            legend: {
                visible: true,
                position: "bottom"
            },
            valueAxis: {
                labels: {
                    format: "N0"
                },
                line: {
                    visible: false
                }
            },
            categoryAxis: {
                labels: {
                    rotation: -90,
                    template: "#= formatApprovalDate(value) #"
                }

            },
            tooltip: {
                visible: true,
                template: "#= series.name #: #= value #"
            },
            seriesDefaults: {
                type: "line",
                style: "smooth"
            },
            series: [
                {
                    field: "Value",
                    categoryField: "Date",
                    name: chartData.SeriesOne.SeriesName,
                    data: chartData.SeriesOne.Items
                },
                {
                    field: "Value",
                    categoryField: "Date",
                    name: chartData.SeriesTwo.SeriesName,
                    data: chartData.SeriesTwo.Items
                }]
        });
于 2014-03-19T22:18:12.683 回答