Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change line colors of chart in Chartist.js

I'm currently using Chartist.js, But I can't change the default line colors of Chart.

Chartist.js

Sample Chart Image

For SIMPLE LINE CHART I've tried:

.ct-series-a .ct-line{
    background-color: blue;
}

But It brings no result. How to fix this?

like image 431
S M Iftakhairul Avatar asked Apr 15 '17 23:04

S M Iftakhairul


People also ask

How to change the color of a line in a chart?

We can use the borderColor property of the dataset to change the color of the line that exists in a line chart. You can assign a color to it in hex or RGBA format. It will take the color and apply it to the lines of a chart created using Chart.js. datasets: [ { label: 'label', data: [90, 40, 50, 70], borderColor: "#084de0" }]

How to use chart JS?

How to Use Chart.js? Chart.js is easy to use. The canvas element must have a unique id. That's all! options: {...} options: {...} If you set the borderColor to zero, you can scatter plot the line graph:

What are the options on the line chart?

options - options for the whole chart The line chart allows a number of properties to be specified for each dataset. These are used to set display properties for a specific dataset. For example, the colour of a line is generally set this way.

How do I create a vertical line chart in HTML?

A vertical line chart is a variation on the horizontal line chart. To achieve this you will have to set the indexAxis property in the options object to 'y' . The default for this property is 'x' and thus will show horizontal lines.


1 Answers

Try this:

.ct-series-a .ct-line {
  /* Set the colour of this series line */
  stroke: red;
  /* Control the thikness of your lines */
  stroke-width: 5px;
  /* Create a dashed line with a pattern */
  stroke-dasharray: 10px 20px;
}

https://gionkunz.github.io/chartist-js/getting-started.html#customizing-the-default-css

like image 180
Diego Rodrigues Avatar answered Sep 28 '22 15:09

Diego Rodrigues