如何更改Highcharts区域中的颜色?

时间:2016-02-15 10:04:55

标签: javascript jquery html highcharts

我有这段代码:

var rawData = [20, 20, 20, 20, 20],
    data = [
        [0, 100]
    ],
    overData = [
        [0, 0]
    ],
    underData = [
        [0, 0]
    ],
    zones = [],
    len = rawData.length,
    colors = Highcharts.getOptions().colors,
    maxColor = colors.length,
    i,
    val,
    sum = 0,
    pos = 0,
    plotLines = [];
    for (i = 0; i < len; i++) {
        sum += rawData[i];
    }

    for (i = 0; i < len; i++) {
        pos += rawData[i];
        val = (sum - pos) / sum * 100;
        data.push([pos, val]);
        overData.push([pos, (100 - val) / 2]);
        underData.push([pos, (100 - val) / 2]);
        zones.push({
            value: pos,
            color: colors[i % maxColor]
        });

    plotLines.push({
        zIndex: 7,
        width: 3,
        color: '#aaa',
        value: pos,
        label: {
            text: rawData[i],
            verticalAlign: 'bottom',
            rotation: 0,
            y: -10,
            align: 'right',
            x: -12,
            style: {
                color: colors[i % maxColor],
                fontWeight: 'bold'
            }
        }
    });
}

现在这条线似乎使用API​​来生成标准的高图颜色:

colors = Highcharts.getOptions().colors

如何为每个“区域”设置我定义的颜色?你能否告诉我一个关于如何为每个区域获得颜色的小样本?

由于

0 个答案:

没有答案