angulartypescriptng2-charts

ng2-charts: Setting colors not working


My chart is defined as:

  <canvas #chart baseChart
              [data]="_chartData"
              [labels]="_chartLabels"
              [chartType]="_chartType"
              [colors]="_backgroundColors">
  </canvas>

I have colors specified as:

private _backgroundColors:string[] = ["#345657", "#112288", "#adf444"];

Everything works but the colors. If I pass this array in, all the colors display as the same color, a light grey. Anyone see what might be wrong?


Solution

  • The solution can be found here. It's not officially documented at this time.

    It needs to be like this:

    [{backgroundColor: ["#e84351", "#434a54", "#3ebf9b", "#4d86dc", "#f3af37"]}]