Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
shifting bars or range label
markcheung
Is there a way to shift the bars in the histogram graph to make it look more like a histogram or change the x-axis's scales' labels?
The label that I am getting is a set of x-axis scales (in CDateTime format), so it is something like 07/ 28 05:00, 7/28 10:00, 7/28 15:00, 7/28 20:00. I have already gotten the frequencies for the time range, and I would like to make it look like a histogram rather than a bar graph. I can either set the scales' label to a set of ranges (07/ 28 00:00 - 07/ 28 05:00, 07/ 28 05:00 - 7/28 10:00, etc) or insert a beginning scale label with no value and shift all the bars to the left.
Again, attached is what my graph currently looks like.
Code snippet:
xAxis = chart.getPrimaryBaseAxes()[0];
xAxis.getLabel().getCaption().getFont().setRotation(45);
// xAxis.setLabelPosition(Position.RIGHT_LITERAL); //error
xAxis.setGapWidth(10); //??
xAxis.getTitle().getCaption().setValue("Time");
xAxis.getTitle().getCaption().setColor(ColorDefinitionImpl.CREAM());
xAxis.getTitle().setVisible(true);
String k=xAxis.getLabel().getCaption().getValue();
System.out.println("Value: "+k); -->print out "Value: " no k value?
Find more posts tagged with
Comments
JasonW
Are you just wanting to remove the space between the bars?
You can do this by setting the unit spacing on the chart:
cwaBar.setUnitSpacing(1);
Jason
markcheung
The space does not really matter. I would like to insert an initial value as the starting point for the histogram. It would have no correspondance on my dataset . Then shift the bars to the left to make it looks like a histogram rather than a bargraph (something likes this: <a class='bbc_url' href='
http://media.techtarget.com/digitalguide/images/Misc/iw_histogram.gif'>http://media.techtarget.com/digitalguide/images/Misc/iw_histogram.gif</a>
; ).<br />
<br />
Right now it is something likes <a class='bbc_url' href='
http://www.neuroscience.com/bargraph.gif'>http://www.neuroscience.com/bargraph.gif</a>
.
JasonW
Would adding to the dataset do what you want? Take a look at the attached example which adds a value to the beginning and end of the chart using the afterDatasetFilledScript.
Jason
markcheung
ok, attached is what I have.
Is there a way to shift the bars to the left (with BIRT Chart Engine), so they will illustratively shows that it is a histogram and not a bar graph. (such that the labels would be at the sides of the bars, rather than the center).
JasonW
You can set a script using the api. Try a script something like the following:
cwaBar.setScript("function beforeDrawSeries( series, seriesRenderer, context )"
+"{if( series.getSeriesIdentifier() == "Series 1" ){"
+"var dpharray = seriesRenderer.getSeriesRenderingHints().getDataPoints();"
+"for( j=0;j<dpharray.length;j++){"
+"var xval = dpharray[j].getLocation().getX();"
+"dpharray[j].getLocation().setX(xval-30);}}}");
Make sure to set the identifier for the bar series like:
bs.setSeriesIdentifier("Series 1");
Jason
markcheung
Worked perfectly. Thanks!