How to solve incorrect grouped bar chart in Chrome?

我的未来我决定 提交于 2019-12-11 14:36:22

问题


I'm creating a grouped bar chart like this:

$("#chart").kendoChart({
        dataSource: {
        data: rawdata,
        group: { field: "Serie" },
    },
    legend: {
        position: "top"
    },
    plotArea: {
        background: "white",
    },
    seriesDefaults: {
        type: "column",
        style: "smooth",
        stack: true
    },
    series: [
        {
            field: 'Valor1',
            labels: {
                visible: true,
                background: '',
                format: 'p1',
                color: 'white',
                position: 'center'
            },
        }
    ],
    valueAxis: {
        max: 1,
        labels: {
            format: "p2"
        },
        line: {
            visible: false
        },
        axisCrossingValue: -10,
    },
    categoryAxis: {
        field: "Segmento",
        majorGridLines: {
            visible: false
        }
    },
    tooltip: {
        visible: true,
        template: "#= series.name # <br /> " +
            "Valor = #= kendo.format('{0:p2}', value) # <br/> " +
            "Tooltip = #= dataItem.Tooltip # ",
    }
});

My data has four properties: Serie, Segmento, Valor1, Tooltip. Example of one data point:

{
    "Serie": "S1",
    "Segmento": "C1",
    "Valor1": 0.31500380634422465,
    "Tooltip": 20,
}

The values of the stack bar are incorrect in chrome but in firefox and ie it's fine.

Correct graph in firefox and ie:

Incorrect graph in chrome:

Here is a live demo: http://trykendoui.telerik.com/anET/9

How can i solve this?


回答1:


This is a problem with Chrome's implementation of Array.sort; see this discussion. You can fix it by sorting the data source explicitly:

dataSource: {
    data: rawdata,
    group: { field: "Serie" },
    sort: [{ field: "Serie", dir: "asc"}, { field: "Segmento", dir: "asc"} ]
},

(updated demo)



来源:https://stackoverflow.com/questions/23582184/how-to-solve-incorrect-grouped-bar-chart-in-chrome

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!