这是一个错误吗?堆叠时间序列会忽略日期值 [英] Is this a bug? Stacking time series ignores the date value

查看:72
本文介绍了这是一个错误吗?堆叠时间序列会忽略日期值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在KendoUI的单个折线图中显示两个系列.

I'm attempting to display two series on a single line chart in KendoUI.

系列中的日期不匹配(也就是说,系列2在系列1之后开始,在系列1之前结束).但是KendoUI会从图表的开头开始渲染这两个系列.

The dates in the series don't match (that is, series two starts after series one, and finishes before series one). KendoUI however renders both series starting from the beginning of the chart.

我已经创建了一个简单的jsfiddle来演示该问题,总结如下:

I've created a simple jsfiddle to demonstrate the issue, summarised here:

HTML:

<div id="chart" />

CSS:

#chart
{
    width: 400px;
    height: 280px;
}

JS:

$(function () {
    var dataSource = new kendo.data.DataSource({
        data: [
            { series: 'Series 1', date: new Date(2013, 04, 01), count: 1 },
            { series: 'Series 1', date: new Date(2013, 04, 02), count: 3 },
            { series: 'Series 1', date: new Date(2013, 04, 03), count: 5 },
            { series: 'Series 1', date: new Date(2013, 04, 04), count: 3 },
            { series: 'Series 1', date: new Date(2013, 04, 05), count: 1 },
            { series: 'Series 2', date: new Date(2013, 04, 02), count: 5 },
            { series: 'Series 2', date: new Date(2013, 04, 03), count: 3 },
            { series: 'Series 2', date: new Date(2013, 04, 04), count: 5 }
        ],

        group: {
            field: 'series'
        },

        sort: {
            field: 'date',
            dir: 'asc'
        },

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

    dataSource.read();

    $('#chart').kendoChart({
        title: {
            text: 'Date Demonstration'
        },

        dataSource: dataSource,

        seriesDefaults: {
            type: 'line'
        },

        series: [{
            field: 'count',
            data: []
        }],

        valueAxis: {
            line: {
                visible: false
            },

            labels: {
                step: 2,
                template: function (value) {
                    return value.value % 1 === 0 ? value.value : ' ';
                }
            }
        },

        categoryAxis: {
            field: 'date',

            type: 'date',

            labels: {
                template: function (value) {
                    return value.value.getDate();
                }
            }
        },

        legend: {
            position: 'bottom'
        }
    });
});

该图的第二个系列应从"2"开始,而不是从"1"开始.

The graph should have the second series starting at '2', instead it starts at '1'.

有人对如何解决此问题有任何想法吗?这是KendoUI中的错误吗?

Anyone have any idea on how to fix this? Is this a bug in KendoUI?

推荐答案

更新:Kendo响应了我们随后打开的支持请求:

UPDATE: Kendo responded to a support request that we subsequently opened:

折线图的工作原理是这样的.您有一些类别,然后为每个类别提供一个值.对于您的情况,我建议您使用散点图,或者您需要使用空值填充第二个序列中的缺失值.

The line chart works like that. You have some categories and then you give a values for each category. In your case I will suggest you to use scatter line chart or you need to fill the missing values from the second series with null as a value.

因此,我认为这是一个不会解决问题的错误,因为在这种情况下,我告诉图表类别轴是日期;然后从数据源给它字段以获取这些日期.图表应能够在正确的日期类别中将这些值绘制到图表上.

I thus consider this a wontfix bug, because in this case I told the chart that the category axis is a date; and then gave it the field from the data source to get those dates from. The chart should be capable of plotting those values to the chart in the correct date category.

这篇关于这是一个错误吗?堆叠时间序列会忽略日期值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆