Chartist-js: Change the fill color for line

Created on 27 Oct 2015  路  10Comments  路  Source: gionkunz/chartist-js

Hi!

I want to change the redish color for the filled line chart but if I use fill: it only fills from the first point to the last point in the line chart. I want to change the red filled color that shows under the line (positive) and over the line (negative).

What should I do to accomplish this?

Most helpful comment

Right. Then depending on how many series you have and how many you wish to affect the following should work:

CSS:

.ct-series-a .ct-area {
    fill: cyan;
}

.ct-series-b .ct-area {
    fill: purple;
}

All 10 comments

Can you show a visual example of what you are trying to achieve?

This image

Just add showArea: true to the options of your chart.

http://gionkunz.github.io/chartist-js/examples.html#example-line-area

That was not my question. My question was how I can change the color of the area!?

Right. Then depending on how many series you have and how many you wish to affect the following should work:

CSS:

.ct-series-a .ct-area {
    fill: cyan;
}

.ct-series-b .ct-area {
    fill: purple;
}

Many thanks :) That did the trick.

Hi woble,

Is it possible to specify a class name through config options to the series I want dynamically to get a particular fill color applied instead of through CSS? More details can be found at https://github.com/gionkunz/chartist-js/issues/635.

Tried as below but it doesn't work:

.series-region {
fill: red;
stroke-width: 1px;
stroke-linecap: square;

    }

series: [
{
name: 'series-1',
className: 'series-region',
data: [
{ x: 0, y: 0 },
{ x: 75, y: 0 },
{ x: 75, y: 23 },
{ x: 100, y: 60 },
{ x: 160, y: 180 }
]
}
.
.
.
.

Thanks,
Shahnavaz

ping, i also want to set the className to use for a series, is this possible?

actually, className worked for me. carry on

Hi woble,

Is it possible to specify a class name through config options to the series I want dynamically to get a particular fill color applied instead of through CSS? More details can be found at #635.

Tried as below but it doesn't work:

.series-region {
fill: red;
stroke-width: 1px;
stroke-linecap: square;

    }

series: [
{
name: 'series-1',
className: 'series-region',
data: [
{ x: 0, y: 0 },
{ x: 75, y: 0 },
{ x: 75, y: 23 },
{ x: 100, y: 60 },
{ x: 160, y: 180 }
]
}
.
.
.
.

Thanks,
Shahnavaz

Thanks so much, this help me !!!

Was this page helpful?
0 / 5 - 0 ratings