TimeSeriesAxisOptions with Bar graphs

29 views
Skip to first unread message

John Smith

unread,
Oct 7, 2014, 2:15:39 PM10/7/14
to gf...@googlegroups.com
Hello,
I am trying to add a bar graph that tracks data over 30 days, so I have 30 points.  I started using CategoriesAxisOptions where the x-axis labels were the string of the date (e.g. "7 Oct 2014").  But doing that made the x-axis really crowded because there were 30 ticks.  So to try to clean it up I tried using TimeSeriesAxisOptions, giving the x-axis as a Long in milliseconds and it converted the milliseconds to a date.  I could space out the tick marks to show the date only every week which looks nice.  However, using this TimeSeriesAxisOptions, the bar graph bars become basically vertical lines with no width, despite me trying to set the width of the bar in BarSeriesOptions later.
Here is my code:

//plotOptions.addXAxisOptions( CategoriesAxisOptions.create().setTickLength(0).setTickColor(gridColor).setFont( FontOptions.create().setColor(axesColor).setWeight("bold").setStyle("italic") ) );

plotOptions
.addXAxisOptions( TimeSeriesAxisOptions.create().setTickSize(7, TickTimeUnit.DAY));



plotOptions
.setGlobalSeriesOptions( GlobalSeriesOptions.create().setBarsSeriesOptions( BarSeriesOptions.create().setShow( true ).setBarWidth( 1 ).setAlignment( BarSeriesOptions.BarAlignment.CENTER ).setFill(0.6) ) );


So when I comment out the CategoriesAxisOptions, the bars become very thin, and when I comment out the TimeSeriesAxisOptions, the bars are the right width.  I want to have the clean x-axis of the TimeSeriesAxisOptions, but the bar width of the CategoriesAxisOptions.  Any suggestions?

Thanks in advance!
CategoriesSeriesOptions.png
TimeSeriesAxisOptions.png

John Smith

unread,
Oct 9, 2014, 2:00:31 PM10/9/14
to gf...@googlegroups.com
By the way, doing the exact same thing with TimeSeriesAxisOptions works with a line graph.  See attached screen shot
LineGraph TimeSeriesAxisOptions.png

Nicolas Morel

unread,
Oct 11, 2014, 7:28:07 AM10/11/14
to gf...@googlegroups.com
Something like this capture ?

Just configure the bar width to 24*60*60*1000.

From the javadoc :
Set the width of the bars in units of the x axis (or the y axis if "horizontal" is true), contrary to most other measures that are specified in pixels. For instance, for time series the unit is milliseconds so 24 * 60 * 60 * 1000 produces bars with the width of a day.


bar.png

John Smith

unread,
Oct 14, 2014, 9:07:32 PM10/14/14
to gf...@googlegroups.com
Wow, thank you.  I did not expect that.
Reply all
Reply to author
Forward
0 new messages