Dynamically custom colors
See original GitHub issueHi, and sorry with my very bad English
I’m making a horizontal chart with ajax, I extract labels, data and colors from the database, and try to paint the chart with the colors of the database, I use two functions:
// use te custom colors f_graph_custom_colors(nId, Fcc); // painting the graph f_graph_paint(nId, Fnombres, data_final); // nId is on graph is painted, Fnombres is an array of labels, and data_final is an array of arrays
I don’t have a problem painting the graph, I have probles utilizing the custom colors there is the function:
function f_graph_custom_colors(nId, Fcc) { // document.head.innerHTML = document.head.innerHTML + '<style>' + nId + ' .ct-series.ct-series-a line {fill: ' + Fcc[0] + ';} ' + nId + ' .ct-series.ct-series-b line {fill: ' + Fcc[1] + ';} ' + nId + ' .ct-series.ct-series-c line {fill: ' + Fcc[2] + ';} ' + nId + ' .ct-series.ct-series-d line {fill: ' + Fcc[3] + ';} ' + nId + ' .ct-series.ct-series-e line {fill: ' + Fcc[4] + ';} ' + '</style>';
I try to inject the css in the header, after the css of the chartist, I read about utilizing custom color changing the css, but I need it dinamically.
Thanks for the responses, and sorry for the inconvenience.
Issue Analytics
- State:
- Created 6 years ago
- Comments:6
Top GitHub Comments
Finish!! Thanks for helping sire, and thanks for your beautiful Lib, This is my final function:
Please read this guide: https://gionkunz.github.io/chartist-js/getting-started.html#dynamic-colouring
Cheers Gion