Multicolor Series Highcharts Module

Typescript-supported Highcharts plugin that adds both line/area multicolor series, where you can define color for each part of a path.

The latest code is available on GitHub: https://github.com/blacklabel/multicolor_series/

General prerequisites

This module requires Highcharts package with the following versions installed in your project:

Installation

NPM

Get the package from NPM in your app:

npm install highcharts-multicolor-series

If Highcharts is not already installed, get the package with Highcharts:

npm install highcharts highcharts-multicolor-series

CDN

Add a <script> tag below the Highcharts script tag:

<script src="https://cdn.jsdelivr.net/npm/highcharts-multicolor-series"></script>

Usage

Basic usage example:

The Live example is available here.

Highcharts.chart('container', {
  series: [{
    type: 'coloredline',
    data: [{
      y: 70,
      segmentColor: 'blue'
    }, {
      y: 20,
      segmentColor: 'green'
    }, {
      y: 40,
      segmentColor: 'yellow'
    }, {
      y: 50,
      segmentColor: 'red'
    }, {
      y: 10,
      segmentColor: 'pink'
    }]
  }]
});

Basic usage example with Typescript (React):

The Live example is available here.

import * as Highcharts from "highcharts";
import HighchartsReact from "highcharts-react-official";

// Implement the package module.
import MulticolorSeries from "highcharts-multicolor-series";
MulticolorSeries(Highcharts);

// The package allows you to import both `Highcharts.SeriesMulticolorLineOptions` and
// `Highcharts.SeriesMulticolorAreaOptions` interfaces, accordingly to the series.
// Interfaces extend the default series options.

const App = () => {
  // Type the chart options.
  const options: Highcharts.Options = {
    series: [
      {
        type: "coloredarea",
        data: [
          {
            y: 40,
            segmentColor: "red"
          },
          {
            y: 60,
            segmentColor: "blue"
          },
          {
            y: 30,
            segmentColor: "yellow"
          },
          {
            y: 10,
            segmentColor: "green"
          },
          {
            y: 50,
            segmentColor: "brown"
          },
          {
            y: 20,
            segmentColor: "pink"
          },
          {
            y: 70,
            segmentColor: "orange"
          }
        ]
      }
    ]
  };

  return <HighchartsReact highcharts={Highcharts} options={options} />;
};

export default App;
      

Parameters

Property Type Required Defaults Description
series.type String Yes - Set it to coloredline or coloredarea to use multicolor series.
point.segmentColor String No - Controls line color between n and n+1 point, independent from point.color, which changes marker color.

Demos

Tests

This package contains tests for the proper elements rendering. To run tests, type:

npm run test

Changelog

The changelog is available here.

License

This package is licensed under MIT.

The package is built on top of the Highcharts library which requires a commercial license. Non-commercial use may qualify for a free educational or personal license. Read more about licenses here.