0
I was answered in a previous question regarding changing colors of my chart, but I want to know how I can change the colors of each bar individually to the colors I want?
Follow the modified code in response by the user Martian Axe:
var chart = new Highcharts.Chart({
chart: {
renderTo: 'container',
type: 'column',
options3d: {
enabled: true,
alpha: 6,
beta: 16,
depth: 100,
viewDistance: 200
}
},
xAxis: {
type: 'category'
},
title: {
text: 'Clientes'
},
subtitle: {
text: 'Gráfico demonstrativo'
},
plotOptions: {
column: {
depth: 25
}
},
series: [{
"colorByPoint": true,
data: [{
"name": "Coluna 1",
"y": 500.94,
"drilldown": "Coluna "
}, {
"name": "Coluna 2",
"y": 106.4,
"drilldown": "Coluna 2"
}, {
"name": "Coluna 3",
"y": 1000.5,
"drilldown": "Coluna 3"
}, {
"name": "Coluna 4",
"y": 144.0,
"drilldown": "Coluna 4"
}]
}]
});
function showValues() {
$('#alpha-value').html(chart.options.chart.options3d.alpha);
$('#beta-value').html(chart.options.chart.options3d.beta);
$('#depth-value').html(chart.options.chart.options3d.depth);
}
$('#sliders input').on('input change', function() {
chart.options.chart.options3d[this.id] = parseFloat(this.value);
showValues();
chart.redraw(false);
});
showValues();
#container,
#sliders {
min-width: 310px;
max-width: 800px;
margin: 0 auto;
}
#container {
height: 400px;
}
<script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/highcharts-3d.js"></script>
<script src="https://code.highcharts.com/modules/exporting.js"></script>
<script src="https://code.highcharts.com/modules/export-data.js"></script>
<div id="container"></div>
<div id="sliders">
</div>
Thank you very much friend. It worked very well, however, just to explain, the code to modify the color should stay within the "date":
– Carlos
True Carlos, outside where I put it changes all colors, ie it is all in the same color, to individually change each series of data have to put the color within the date. I adjusted my answer to agree
– rnd_rss
Could you help me with one more thing? I wanted to pass the value of a php variable in this script. Ex.: <?php $test="900"; ? > in the column value.
– Carlos
Open another question, I haven’t touched php in a while and it’s easier for someone to help you
– rnd_rss
Blza. I’ll do it. Thanks.
– Carlos