Highcharts,将错误栏与数据模块一起使用

Highcharts, use error bar with Data Module

本文关键字:模块 一起 数据 错误 Highcharts      更新时间:2023-09-26

我们使用的Highcharts柱状图与以下示例完全相同:

http://jsfiddle.net/gh/get/jquery/1.7.2/highslide-software/highcharts.com/tree/master/samples/highcharts/data/rows/

$(function () {
$('#container').highcharts({
    chart: {
        type: 'column'
    },
    title: {
        text: 'Data input as row arrays'
    },
    data: {
        rows: [
            [null, 'Ola', 'Kari'], // series names
            ['Apples', 1, 5], // category and values
            ['Pears', 4, 4], // category and values
            ['Oranges', 3, 2] // category and values
        ]
    }
});

});

因此,对于图表数据,我们使用的不是序列,而是数据行。

有没有一种方法可以在这个柱状图中添加误差条,以及如何做到这一点?

Thankz,walter

我自己也为此挣扎了一段时间,终于想通了。诀窍是定义序列并给它们一个id。之后,您可以将错误栏链接到正确的系列。

$(function () {
$('#container').highcharts({
    chart: {
        type: 'column'
    },
    title: {
        text: 'Data input as row arrays'
    },
    tooltip: {
        shared: true
    },

    data: {
        rows: [
            [null, 'Ola', 'Kari'], // series names
            ['Apples', 1, 5], // category and values
            ['Pears', 4, 4], // category and values
            ['Oranges', 3, 2] // category and values
        ]
    },
    series: [
        {
            id: '0'
        },
        {
            id: '1'
        },
        {
            type: 'errorbar',
            data: [[0, 3], [1, 3],[2, 1]],
            linkedTo: '0'
        },
        {
            type: 'errorbar',
            data: [[0, 6], [2, 5],[3, 2]],
            linkedTo: '1'
        }
    ]
});

});

有关示例,请参见更新的小提琴:http://jsfiddle.net/6k7ee0cu/1/