我正在尝试从谷歌图表中自定义蜡烛图。
我已经找到如何改变蜡烛本身的颜色,但不是指示最高值和最低值的那条线的颜色:
这些是我提供的选项:
let options = {
legend: 'none',
candlestick: {
risingColor: {stroke: '#4CAF50', fill: 'white'},
fallingColor: {stroke: '#F44336'}
}
}
你可以在这个 jsFiddle 上试试:https://jsfiddle.net/El_Matella/h5p36t3w/2/
我在文档中找不到如何更改它,有人有想法吗? ( https://developers.google.com/chart/interactive/docs/gallery/candlestickchart )
最佳答案
如果你希望所有的线条都是相同的颜色,
您可以使用 colors
选项...
请参阅以下工作片段...
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.com/charts/loader.js"></script>
<div id="chart_div" style="width: 900px; height: 500px;"></div>
关于javascript - 谷歌图表烛台颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47641895/