Highcharts How To Change Series Color with examples

To change the color of a series in Highcharts, there are a set of options we are going to discover in this article.

Option 1: Using the color option in the series object:

you can use the color option in the series object. Here is an example of how you can do this:

chart: {
    type: 'line'
},
title: {
    text: 'Line chart with different series colors'
},
xAxis: {
    categories: ['Jan', 'Feb', 'Mar']
},
yAxis: {
    title: {
        text: 'Y-axis'
    }
},
series: [{
    name: 'Jane',
    data: [1, 0, 4],
    color: '#FF0000' // red
}, {
    name: 'John',
    data: [5, 7, 3],
    color: '#00FF00' // green
}]

Option 2: Using the color property in the point object:

You can also specify a color for an individual point in a series using the color property in the point object.

chart: {
    type: 'line'
},
title: {
    text: 'Line chart with different point colors'
},
xAxis: {
    categories: ['Jan', 'Feb', 'Mar']
},
yAxis: {
    title: {
        text: 'Y-axis'
    }
},
series: [{
    name: 'Jane',
    data: [{
        y: 1,
        color: '#FF0000' // red
    }, {
        y: 0,
        color: '#00FF00' // green
    }, {
        y: 4,
        color: '#0000FF' // blue
    }]
}]

Option 3: Using the colors option in the chart configuration object:

Alternatively, you can use a pre-defined color scheme by setting the colors option in the chart configuration object.

chart: {
    type: 'line',
    colors: ['#FF0000', '#00FF00', '#0000FF'] // red, green, blue
},
title: {
    text: 'Line chart with predefined colors'
},
xAxis: {
    categories: ['Jan', 'Feb', 'Mar']
},
yAxis: {
    title: {
        text: 'Y-axis'
    }
},
series: [{
    name: 'Jane',
    data: [1, 0, 4]
}, {
    name: 'John',
    data: [5, 7, 3]
}]

Related Posts

How to Capture Screenshots with Puppeteer In NodeJS

How to Capture Screenshots with Puppeteer In NodeJS

To Capture Screenshots with Puppeteer: Launch a Browser Instance Navigate to the Web Page Capture the Screenshot Introduction: Puppeteer is a powerful Node.js library that allows developers…

How to Minimize Puppeteer Browser Window To Tray

How to Minimize Puppeteer Browser Window To Tray

Puppeteer is a powerful tool for automating tasks in headless or non-headless web browsers using JavaScript. While Puppeteer is often used to perform actions within a browser,…

Intercepting Responses in Node.js with Puppeteer

Intercepting Responses in Node.js with Puppeteer

Introduction: Puppeteer is a powerful Node.js library that provides a high-level API for controlling headless Chrome or Chromium browsers. It’s widely used for web scraping, automated testing,…

Mastering React Component Re-rendering in Jest

Mastering React Component Re-rendering in Jest

In this hands-on guide, we’ll explore the art of optimizing React component re-rendering within Jest tests. By combining theory with practical coding examples, you’ll gain a deep…

Eliminating Nesting Loops in React Rendering

Eliminating Nesting Loops in React Rendering

React has ushered in a new era of web application development with its component-based structure, promoting code reusability and maintainability. But as projects evolve, achieving optimal performance…

Exploring Type and Interface Usage in TypeScript

Exploring Type and Interface Usage in TypeScript

TypeScript has gained immense popularity by bridging the gap between dynamic JavaScript and static typing. Two of its fundamental features, “Type” and “Interface,” play pivotal roles in…

Leave a Reply

%d bloggers like this: