Highcharts: setOptions for two different series of charts?

highcharts set options dynamically
highcharts setoptions lang
highcharts setoptions colors
highcharts options typescript
highcharts series options
highcharts api
highcharts documentation
highcharts renderto

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.

Thanks.

SetOptions can be used single time, because overwrites global settings, and again calling doens't work.

How to set options, Note that the two options objects will produce exactly the same result. // Good code: var options = {. chart: {. renderTo: 'container',. type: 'bar'. },. series: [{. var chart = new Highcharts.Chart(options); After an object is created using the object literal notation, we can extend its members by the dot notation. Say we have an object like defined in the "Good code" above. The code below adds another series to it. Remember options.series is an array, so it has a push method.

SetOptions Can be used only once in highcharts.

See jsfiddle. It is releveant to your question. It shows how to use SetOptions for multiple charts.

Set Options in Highcharts, where there might be several completely different graphs (with forEach((option, i) => Highcharts.chart(i+'', option)) // Update all charts title after 2 seconds populate options1 series with data from JSON retrieved from DB plotOptions.series.compare. Compare the values of the series against the first non-null, non- zero value in the visible range. The y axis will show percentage or absolute change depending on whether compare is set to "percent" or "value". When this is applied to multiple series, it allows comparing the development of the series against each other.

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. 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.

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

e.g. - 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,
      },
    ],
  }

Two different themes on the same page with two separate charts , I have two different types of charts on this dashboard page but I cannot seem to apply the setOptions(Highcharts.piechart_theme); . $(function () { var treemap_chart = Highcharts.chart('treemap_container', { series: [{ type:  0 I am using Highcharts.js to create some charts for a dashboard on a web application. I have two different types of charts on this dashboard page but I cannot seem to apply the two differing themes I have.

Combining chart types, To combine several chart types in one chart you only need to create series of different types: series: [{. type: 'column',. name: 'Jane',. data: [3, 2, 1, 3, 4] }, {. In styled mode, the color can be defined by the colorIndex option. Also, the series color can be set with the .highcharts-series , .highcharts-color- {n}, .highcharts- {type}-series or .highcharts-series- {n} class, or individual classes given by the className option. Defaults to undefined.

Series, A series is a set of data, for example a line graph or one set of columns. All data General options that apply to multiple series are defined in the plotOptions. A two-dimensional array representing the input data on tabular form. This input can be used when the data is already parsed, for example from a grid view component. Each cell can be a string or number. If not switchRowsAndColumns is set, the columns are interpreted as series. Defaults to undefined.

Multiple charts and time sync, I'm trying to create multiple charts on a single page that are in time sync i.e the x setOptions({ global: { useUTC: false } }); // Create the chart  plotOptions.series.linkedTo. The id of another series to link to. Additionally, the value can be ":previous" to link to the previous series. When two series are linked, only the first one appears in the legend. Toggling the visibility of this also toggles the linked series.

Comments
  • Thanks, is there a way to pass the series data outside of the options variable?
  • for that you need use json data and call it using ajax