I am using Google Chart API, primarily Combo Chart to display different data in the same graph area. When I use CandleStick alone it looks fine:
However when I add another bar series it causes slight shift and now candles look all messed up.
It seems that width of left Vertical axis causes this slight shift. Problem is, I need both axis shown. I tried adjusting strokewidth
of both falling and rising, it just make it look fuzzy. So making strokewidth
to less than 1 is not too effective.
Code
var options = {
title: jsondata['chart_title'],
hAxis: {direction: -1},
vAxes: {0:{format:y_units},1:{format:"$#.##"}},
seriesType: "bars",
series: {0: {type: "candlesticks", targetAxisIndex: 1}},
candlestick: {
fallingColor:{
strokeWidth: .5
},
risingColor:{
strokeWidth: .5
}
},
displayAnnotations: true,
crosshair: { trigger: 'both' }
}
and actual drawing element
var chart = new google.visualization[jsondata['chart_type']](document.getElementById('chart_div'));
$.extend(options, {legend:{position:'bottom'}})
chart.draw(data, options);
Sample Data
['Mon', 11, 10, 8, 17, 1],
['Tue', 12, 17, 7, 28, 5],
['Wed', 6, 22, 5, 25, 0],
['Thu', 10, 11, 16, 11, 0],
['Fri', 15, 44, 25, 44, 3]
Any suggestions to make it look normal?
This effect happens when you have too many bar-type (candlestick and bar) data points in a chart for the width of the chart. When using a discrete (string-type) axis, each row of data is allocated (width / rows) pixels for the bar group, and bars are aligned side-by-side within the group, which generates some odd effects when the group width gets narrow. You can address this problem by using some combination of the following:
bar.groupWidth
option, set to '100%'
to maximize) isStacked
option to true
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.