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)
Charts do not fit my data.
leonelag
The attached image shows a chart in my app.
As you can see, it's a time series, with one year worth of data, from May 2008 to May 2009.
Now, the X axis also shows labels for April 2008 and Jun 2009, so there is a gap between the start of the curve and the Y axis, and another at the end of the curve.
How do I make the X-axis start at May 2008 and end at May 2009, i.e., the first and last points of data ? I want the curve to touch the Y axis on the left and span all the way to the right side of the chart.
Find more posts tagged with
Comments
bhanley
Are you doing any grouping or aggregation on the data that could be causing you to lose values? I have a line chart plotting 365 values that goes end-to-end without dropping anything (see attached). I did apply grouping on the X-Axis to get the intervals to fall roughly monthly (it is not exact).
What format are the data in? Can you share the design and data? I would be happy to have a look.
leonelag
No data is lost. All my data lies between May 08 and May 09. I just wish to remove the gap before the data and after it to remove the illusion that the chart is displaying data for April 08.
I have extracted the chart from my report and copied it to an empty report, to avoid the noise around it.
Find the report and the data in the attachments.
bhanley
I adjusted the min and max on the X Axis Scale (See attached thumbnail) and got the report working correctly. I think the issue came into play because of the 1-month step you applied to the X Axis. It cause a bit of bleed on either side of the data set, hence the gap.
The updated, functioning report is also attached. Hope this gives you what you need.
leonelag
<blockquote class='ipsBlockquote' ><p>I think the issue came into play because of the 1-month step you applied to the X Axis. It cause a bit of bleed on either side of the data set, hence the gap.<br /></p></blockquote>
<br />
Indeed. Tweaking the size of the step on the X axis to 1 year or 1 day also creates gaps 1 year or 1 day wide.<br />
<br />
<blockquote class='ipsBlockquote' ><p>I adjusted the min and max on the X Axis Scale (See attached thumbnail) and got the report working correctly. <br />
<br />
The updated, functioning report is also attached. Hope this gives you what you need.<br /></p></blockquote>
<br />
Thanks for your time. Unfortunately, that won't work, as my data is dynamic, and it seems the min and max are frozen.<br />
<br />
Is it possible to set the min and max on the axis scale to be the min and max value from the data set ? I wish that were the default.
leonelag
Solved.<br />
<br />
Solved it by adding a script to the chart:<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
function afterDataSetFilled( series, dataSet, icsc )
{
importPackage(Packages.org.eclipse.birt.chart.model.data.impl);
if (series.getSeriesIdentifier() == "") {
// X series.
var values = dataSet.getValues()
var minX = values[0], maxX = values[0]
for (i = 0; i < values.length; i++) {
if (values[i].compareTo(minX) < 0) minX = values[i];
if (values[i].compareTo(maxX) > 0) maxX = values[i];
}
var xAxis = icsc.getChartInstance().getBaseAxes()[0]
xAxis.getScale().setMin(DateTimeDataElementImpl.create(minX))
xAxis.getScale().setMax(DateTimeDataElementImpl.create(maxX))
}
}
</pre>
<br />
<br />
It's not pretty, but it works well enough.<br />
<br />
Edit: this script is added to the onRender event of the chart. To do that, left-click on the chart in the layout view to select it, then choose the Script view. This will open the Script editor for the chart.
RakhiR
<p>Thanks a lot for this solution
</p>