我可以为每个点提供JSON数据的颜色信息吗

我可以为每个点提供JSON数据的颜色信息吗

本文介绍了HighCharts OHLC - 我可以为每个点提供JSON数据的颜色信息吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

首先感谢这个优秀的社群!

first thanks for this great community!

我在Highcharts文件中找不到任何内容,也没有在stackoverflow或Google上找到任何内容。

I didn't find anything in the Highcharts Docs and also nothing on stackoverflow or Google.

我想通过传递JSON来为OHLC-Chart中的每一个点提供填充颜色信息。这是可能吗?

I would like to provide fill-color informations for each point in the OHLC-Chart by passing it through JSON. Is this possible?

这是我的JSON(例如)

Here is my JSON (for example)

[[973033200000,10.18,10.18,10.74,10.18],
[973119600000,10.16,10.16,10.72,10.16],
[973465200000,10.1,10.1,10.66,10.1],
[973551600000,10.16,10.16,10.72,10.16],
[973638000000,10.17,10.17,10.73,10.17],
[973724400000,10.2,10.2,10.77,10.2]]

我的目的的替代方法是使用jQuery更改日期范围的点颜色。
这可能吗?

An alternative for my purposes would be to change the point-colors for a date-range with jQuery.May this is possible?

谢谢您回答!

推荐答案

您可以传递每点颜色的信息,例如

You can pass information of color per point like this http://jsfiddle.net/gvkv4f50/1/

$(function () {
    // create the chart
    $('#container').highcharts('StockChart', {
        plotOptions: {
            ohlc: {
                colorByPoint: true,
            }
        },

        rangeSelector: {
            inputEnabled: $('#container').width() > 480,
            selected: 2
        },

        title: {
            text: 'AAPL Stock Price'
        },

        series: [{
            type: 'ohlc',
            name: 'AAPL Stock Price',
            data: [{
                open: 8.34,
                high: 8.56,
                low: 5.47,
                close: 6.15,
                color: 'yellow'
            }, {
                open: 8.34,
                high: 8.56,
                low: 5.47,
                close: 6.15,
                color: 'green'
            }],
            dataGrouping: {
                units: [
                    [
                        'week', // unit name
                    [1] // allowed multiples
                    ],
                    [
                        'month', [1, 2, 3, 4, 6]]
                ]
            }
        }]
    });
});

如果要在打开点的值低于关闭点时忽略不同的着色,请添加:

If you want to ignore different coloring when open point has lower value than close point add this:

 Highcharts.wrap(Highcharts.seriesTypes.ohlc.prototype, 'getAttribs', function (p, args) {
    Highcharts.seriesTypes.column.prototype.getAttribs.apply(this, args);
});

您可以在这里查看 -

You can see how in here - http://jsfiddle.net/chybv1mt/3/

这篇关于HighCharts OHLC - 我可以为每个点提供JSON数据的颜色信息吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-11 12:57