telerik kendo 图表绑定到字符串

telerik kendo chart bind to string

我是 telerik 新手 kendo 图表 我创建了一个从 ashx 页面返回的字符串。我希望 x 轴是月份和年份中的日期,并且对于每个日期,都会有两个框上升到数字。

Is it the way I am sending the string back from the ashx page?

ASHX.CS 页

    string JSON = sb.ToString();

    context.Response.ContentType = "text/json";
    context.Response.Write(JSON);

[
    {
    "Date":"2/2018"
    "Images":"199956"
    "ImagesDownloads":"540903"
    },
{
    "Date":"3/2018"
    "Images":"226606"
    "ImagesDownloads":"635068"
    }
]

在我的 JS 页面中

var DataSource = new kendo.data.DataSource({
      transport: {
      read: {
      url: function() {
      return "/URI";
      },
      dataType: "json"
      }
      },

      group: {
      field: "Date"
      },

      sort: {
      field: "Date",
      dir: "asc"
      },

      schema: {
      model: {
      fields: {
      date: {
      type: "date"
      }
      }
      }
      }
      });

      function createChart() {
      $("#chart1").kendoChart({
      dataSource: DataSource,
      legend: {
      position: "bottom"
      },
      series:
        [{
          field: "Images",
          categoryField: "Date",
          name: "Number of Images"
          }, {
          field: "ImagesDownloads",
          categoryField: "Date",
          name: "Number of Images download"
        }],
      categoryAxis: {
      field: 'Date'
      },
      tooltip: {
      visible: true,
      shared: true
      }
      });
      }

      $(document).ready(function () {


      $(document).ready(createChart);
      $(document).bind("kendo:skinChange", createChart);

请参考this demo for grouped data bar chart。 此演示还向您展示了 Kendo 如何支持类别轴上的日期格式,您可以使用 API Reference 了解更多信息。