带有多个孩子的Kendo UI Chart DataSource

时间:2016-11-17 23:08:42

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

我有一个远程数据,我正在尝试构建Kendo UI Chart的DataSource。远程数据代表大多数图表的通用数据模型。模型就是这样,

     model: {
          fields: {
             Title: { field: "Title", type: "string" },
             XLabel: { field: "XLabel", type: "string" },
             YLabel: { field: "YLabel", type: "string" },
             Legend: [
                 {?????????{ type: "string" }}
                  ]
          },
          hasChildren: true,
          children: "ChartDataSets"
       }
     }

远程数据样本:

    {
      "Chart": [
        {
          "Title": "1",
          "XLabel": "",
          "YLabel": "",
          "Legend": [ "P1","P2","P3"],
          "ChartDataSets": [
                   {
                      "GroupName": "Week 0",
                       "Series": [
                         {
                           "Key": "2015",
                           "Value": 42
                         },
                         {
                           "Key": "2016",
                           "Value": 42
                         }
                       ]  
                    },
                   {
                      "GroupName": "Week 1",
                       "Series": [
                         {
                           "Key": "2015",
                           "Value": 52
                         },
                         {
                           "Key": "2016",
                           "Value": 32
                         }
                       ]  
                    }
           ]
         }
      ]
   }...

因此Legend是一个字符串数组,ChartDataSets是一个json对象数组。如何将Legend表示为阵列或者它有孩子?

另外,您是否建议使用Hierarchical DataSource?如果我使用Hierarchical DataSource,性能会受到什么影响?

__________没关系 - 发现它____________ 解决方案:

     model: {
          fields: {
             Title: { field: "Title", type: "string" },
             XLabel: { field: "XLabel", type: "string" },
             YLabel: { field: "YLabel", type: "string" },
             Legend: [{field: "Legend"}]
          },
          hasChildren: true, ...

0 个答案:

没有答案