Home Forums Chart Support How to define your own color set for a ReactJS canvas component?

How to define your own color set for a ReactJS canvas component?

Viewing 5 posts - 1 through 5 (of 5 total)
  • #23819

    I am using the ReactJS canvasJS components.

    How do I define a custom color set?

    This link shows me how to do it in vanilla JS, but I’m looking for a ReactJS method.
    https://canvasjs.com/docs/charts/chart-options/colorset/

    Thanks.

    #23826

    @ttchuah,

    Defining custom color-set array using addColorSet method works fine in Vanilla JS, React, Angular, etc. Please take a look at this sample project.


    Vishwas R
    Team CanvasJS

    #25293

    The solution works great!

    #44860

    Hey, could you provide some guidance on how to achieve this in Angular?

    #44863

    @sameer89,

    You can import CanvasJS from angular-charts package to add custom colorset as shown in the code-snippet below.

    import { CanvasJS } from '@canvasjs/angular-charts';
    CanvasJS.addColorSet('customColorSet', ['#4661EE', '#EC5657', '#1BCDD1', '#8FAABB', '#B08BEB', '#3EA0DD', '#F5A52A', '#23BFAA', '#FAA586', '#EB8CC6']);

    Please take a look at this Stackblitz for an example of the same.

    Chart with Custom Colorset


    Vishwas R
    Team CanvasJS

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.