繁体   English   中英

Kendo-UI中的多个线系列

[英]Multiple Series of Line in Kendo-UI

我想绘制两个数据集(stats和stats2)。

我可以画一个系列(统计数据),

dataSource: {  data: stats},

http://jsfiddle.net/1sgt4810

但是当我添加第二个时,它不会绘制。

dataSource: {  data: stats, stats2 },

http://jsfiddle.net/1sgt4810/2/

我知道有如下选择

                      series: [{
                            type: "line",
                            field: "y",
                            categoryField: "x",
                            name: "Path1",
                            style: "smooth",
                            data: stats,
                            markers: {
                             visible: false
                          }
                        }, {
                            type: "line",
                            field: "y",
                            categoryField: "x",
                            name: "Path2",
                            style: "smooth",
                            data: stats2,
                            markers: {
                             visible: false
                          }
                        }],

因为将来会有很多行,所以我需要知道如何以模块化的方式处理多行。

选项1

除了使用dataSource ,您还可以提供多个series并为每个series赋予一个data属性。 您可以在Kendo UI网站的示例中看到这一点。

series: [{
    name: "Path1",
    //other properties
    data: stats
}, {
    name: "Path2",
    //other properties
    data: stats2
}],

是更新的小提琴 ,同时显示了两行。 我不相信没有多个系列就没有办法。

选项2

如果要将线合并为一,则可以将数组连接起来,如下所示:

dataSource: [].concat(stats, stats2)

这是一个小提琴

选项3

另一种可能性是根据您拥有的阵列数来生成序列。 例如:

series: [ stats, stats2 ].map(function (data, idx) {
    return {
        type: "line",
        field: "y",
        categoryField: "x",
        name: "Path" + (idx + 1),
        style: "smooth",
        data: data,
        markers: {
            visible: false
        }
    };
})

您可以在这里看到。

查看您的jfiddle问题是,您试图将两个stats数组传递到数据源中,并希望它为您画一条线,而您需要修改退出的stat

 { x: 1227.35612555829, y: 6016.67309037634,  z: 6013.67309037634},

看看http://jsfiddle.net/1sgt4810/19/

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM