【问题标题】:Highcharts create chart with coloraxis objectHighcharts 使用 coloraxis 对象创建图表
【发布时间】:2023-03-30 22:05:02
【问题描述】:

我有一个代码,可以根据保存的参数创建一个高图表。我通过首先创建一个对象来创建它——这不是 highcharts 建议的方式,但对于我的目的来说是必要的。

我似乎找不到将 colorAxis 及其属性传递给要创建的图表的正确方法。这是我尝试过的:

  1. colorAxis 作为一个对象,在主图表上只是一个对象。

    thischart.colorAxis={}; thischart.colorAxis.stops=...包含信息的数组数组... thischart.colorAxis.min=window[PlotID].colorAxis.min; thischart.colorAxis.max=window[PlotID].colorAxis.max;

    ...其他参数...

    ...new Highcharts.Chart(thischart);

  2. colorAxis 作为主图表上的一个对象,带有一个数组。

    thischart.colorAxis=new Array();
    thischart.colorAxis['0']={};
    thischart.colorAxis['0'].stops=...包含信息的数组数组... thischart.colorAxis['0'].min=window[PlotID].colorAxis.min; thischart.colorAxis['0'].max=window[PlotID].colorAxis.max;

    ...其他参数...

    ...new Highcharts.Chart(thischart);

老实说,我已经使用这个软件好几个月了,缺乏文档实在令人沮丧,尤其是在更改已经存在的图表方面。我错过了什么吗?除了主要文件之外,还有其他文件可以解释如何做这样的事情吗?

谢谢

【问题讨论】:

    标签: highcharts


    【解决方案1】:

    刚刚尝试了您的解决方案:http://jsfiddle.net/24qf98xL/

    options.colorAxis = {};
    options.colorAxis.min = 0;
    options.colorAxis.minColor ='#FFFFFF';
    options.colorAxis.maxColor = Highcharts.getOptions().colors[0];
    
    $('#container').highcharts(options);
    

    如您所见,一切正常。

    关于文档,官方API可以在here和'Axis'下面找到。如果您使用的是此处未列出的其他方法,那么您使用的是内部方法,这些方法没有也不会被描述。


    【讨论】:

    • 感谢您的回答。我已经让这些工作了,但我仍然无法停止工作。尝试了 options.colorAxis.stops=... ,其中 ... 是数组、对象和文​​本。这些都不适合我。
    • 好的,因此将停靠点作为数组输入也可以在您提供的小提琴中使用。因此,看来我的问题不在于停靠点,而在于其他问题。知道什么会导致第 22 行出现此错误 Uncaught TypeError: Array.prototype.forEach called on null or undefined
    • 这意味着你应该有一个数组但你有一个空值。你能在 jsfiddle 上重新创建问题吗?或者你有一些演示页面吗?
    • 嘿,我发现了问题。显然,设置 lineWidth 参数会导致热图失败。感谢您的帮助。
    猜你喜欢
    • 1970-01-01
    • 2015-09-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多