简体   繁体   English

Highcharts:两个不同系列图表的setOptions?

[英]Highcharts: setOptions for two different series of charts?

I have a total of eight small fever charts. 我总共有八张小发烧图表。 Four for grants and four charts for loans. 四个用于赠款,四个用于贷款图。

Using: 使用:

Highcharts.setOptions({
    chart: {
        backgroundColor: null
    }, 
    etc...
});

and then access those settings using: 然后使用以下命令访问这些设置:

var chart1 = new Highcharts.Chart({
    chart: {renderTo: 'smallChart1'},
    series: [{data: [13334, 14376, 15825, 16267]}]
});

I am able to make the first four charts all follow the single set of options. 我能够使前四个图表都遵循单个选项集。

So that works fine. 这样就可以了。 But now I want to setOptions for the second group of charts but I don't know how to make a second set of setOptions the other four charts can share. 但是现在我想为第二组图表设置setOptions,但是我不知道如何制作其他四个图表可以共享的第二组setOptions。

Thanks. 谢谢。

SetOptions可以一次使用,因为它会覆盖全局设置,并且再次调用无效。

SetOptions Can be used only once in highcharts . SetOptionshighcharts只能使用一次。

See jsfiddle . 参见jsfiddle It is releveant to your question. 这与您的问题无关。 It shows how to use SetOptions for multiple charts. 它显示了如何对多个图表使用SetOptions

If you want to set different options for different charts, just don't use the global configuration. 如果要为不同的图表设置不同的选项,请不要使用全局配置。 Only use the global setOptions({ ... }) for things you want to be the same in every chart. 仅对要在每个图表中保持相同的内容使用全局setOptions({ ... }) To override the options for the series just pass in the styles. 要覆盖该系列的选项,只需传递样式即可。

for example, say I wanted the font to be the same in every chart and a minPointLength , but I wanted more fine tuned control in the series... It might look something like this. 例如,假设我希望每个图表中的字体都和minPointLength ,但是我希望该系列中的控件进行更精细的调整……看起来可能像这样。

// global configuration
Highcharts.Highcharts.setOptions({
  chart: {
    style: {
      fontFamily: '"FFMarkWebProRegular", Helvetica, Arial, sans-serif',
    },
  },
  plotOptions: {
    series: {
      minPointLength: 1, // global setting on series
    },
  },
});

eg - the configuration for a given plot 例如-给定图的配置

// specific waterfall plot
const config = {
    title: null,
    chart: {
      type: 'waterfall',
    },
    series: [
      {
        borderWidth: 0,  // more specific settings
        ...
        data: waterfallData,
        pointPadding: 0,
      },
    ],
  }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM