Google bar chart: moving zero axis up, painting negative valuse red
I have the following chart for displaying "virtual money" in a weekly game tournament (player money is dark blue, compared to best player money values in light blue):
http://chart.apis.google.com/chart?chs=700x280&cht=bvo&chco=4D89F9,C6D9FD&chd=t:713,-647,-1202,-1830|3927,6133,8053,2576&chxl=0:|2010-44|2010-45|2010-46|2010-47&chxt=x,y&chxr=1,-1830,8053&chds=-1830,8053&chbh=140&chm=N,,0,,12|N,,1,,12
1) Is there please a way to the X-axis up a bit, so that the negative dark blue bars appear below it?
2) Is there a way to append a "$" to the values (instead of prepending with cUSD)?
3) Is there a way to paint only negative values red? Can't find this in th开发者_开发知识库e doc, I only see how to make them all red with N,FF0000,0,,12
Thank you! Alex
The zero line can be added as horizontal marker line going through y=0, you'll still get the odd 'x-axis' on the bottom of the graph, but this was acceptable for me at least.
Just add an additional data series chd=[your data]|0
and an additional marker chm=[your markers]|H,000000,2,1,1
[ H=horizontal line, 000000=hexadecimal for black, 2=the index of the last data series, 1=width of 1px, 1=z-index of 1 (in front of stacked bars) ]
so the final chart looks like this:
PS: I know this is a rather old question and you have probably moved on, but I came accross this question when I myself was looking for answers to 1) and 3), Nick's answer took care of 3) [thanks Nick] but 1) wasn't answered. So this is just for anyone else stumbling accross this question as I did.
You can only list the individual dataset colors with chco
, so you can certainly make the bottom dataset red (as you've done with the blue), but not just the negative members. My suggestion for making the negative members red is making a 3rd negative data set overlapping the positive data set, where the values are _
when they're not negative so you don't draw a bar (_
or __
indicates a missing value, depending on your encoding type). You'd have something like:
chd=t:713,_,_,_|_,-647,-1202,-1830|3927,6133,8053,2576
chco=4D89F9,FF0000,C6D9FD
You'll probably have to play with the ordering a bit and the data style attributes in order to get the colors and labels to be the way you want them.
As far as I know there's no way to move the X axis up to zero on the chart (it can only go on either top or bottom), but you can make it invisible (while still leaving the labels) using chxs
, which might give you a better look.
I've managed to append $ with N**$
精彩评论