I am trying to customize candlecharts from google charts.
I have found how to change the color of the candle themselves, but not the one of the line indicating the highest and lowest value:
Those are the options I provided:
let options = {
legend: 'none',
candlestick: {
risingColor: {stroke: '#4CAF50', fill: 'white'},
fallingColor: {stroke: '#F44336'}
}
}
You can try it on this jsFiddle: /
I can't find in the documentation how to change it, does someone have an idea? ()
I am trying to customize candlecharts from google charts.
I have found how to change the color of the candle themselves, but not the one of the line indicating the highest and lowest value:
Those are the options I provided:
let options = {
legend: 'none',
candlestick: {
risingColor: {stroke: '#4CAF50', fill: 'white'},
fallingColor: {stroke: '#F44336'}
}
}
You can try it on this jsFiddle: https://jsfiddle/El_Matella/h5p36t3w/2/
I can't find in the documentation how to change it, does someone have an idea? (https://developers.google./chart/interactive/docs/gallery/candlestickchart)
Share Improve this question edited Dec 7, 2017 at 13:20 WhiteHat 61.3k7 gold badges53 silver badges136 bronze badges asked Dec 4, 2017 at 21:01 HammerbotHammerbot 16.4k13 gold badges66 silver badges108 bronze badges 4- 1 I have the same problem but I need these lines to be red or green, according to rising and falling colors. I think API doesnt make it possible :| – Łukasz Ostrowski Commented Sep 11, 2018 at 12:09
- Hi, you should post a new question, I can't find anything in the documentation to resolve your problem... – Hammerbot Commented Sep 11, 2018 at 12:13
- I know, I think its just not possible and this lib is not open source, so I will look for apternatives – Łukasz Ostrowski Commented Sep 11, 2018 at 12:14
- You could look at the d3 js library, I think google uses it under the hood. Its API is not the easiest one tho – Hammerbot Commented Sep 11, 2018 at 12:29
2 Answers
Reset to default 5if you want all the lines to be the same color,
you can use the colors
option...
see following working snippet...
google.charts.load('current', {'packages':['corechart']});
google.charts.setOnLoadCallback(drawChart);
function drawChart() {
var data = google.visualization.arrayToDataTable([
['Mon', 20, 28, 38, 45],
['Tue', 31, 38, 55, 66],
['Wed', 50, 55, 77, 80],
['Thu', 77, 77, 66, 50],
['Fri', 68, 66, 22, 15]
// Treat first row as data as well.
], true);
var options = {
legend:'none',
candlestick: {
risingColor: {stroke: '#4CAF50', fill: 'white'},
fallingColor: {stroke: '#F44336'}
},
colors: ['magenta']
};
var chart = new google.visualization.CandlestickChart(document.getElementById('chart_div'));
chart.draw(data, options);
}
<script type="text/javascript" src="https://www.gstatic./charts/loader.js"></script>
<div id="chart_div" style="width: 900px; height: 500px;"></div>
As I'm using jQuery for other stuff and still no official solutions (afaik) from Google, I ended up with this:
jQuery('div[id*="chart_div"] svg g g[clip-path] g:nth-of-type(3) g' ).each(function() {
jQuery(this).find('rect:first-of-type').attr('fill',jQuery(this).find('rect:nth-of-type(2)').attr('fill'));
});
(Please note the official examples have only one chart, mine page has several, hence each one has a unique id like chart_div_uniqueid, so evertything wrapped into a .each.)
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744259303a4565550.html
评论列表(0条)