Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » BIRT » Dynamically add a marker line to a chart
Dynamically add a marker line to a chart [message #725746] Thu, 15 September 2011 16:29 Go to next message
Mike Wulkan is currently offline Mike WulkanFriend
Messages: 147
Registered: July 2009
Senior Member
Hi,

I have a Chart with bar series. I would like place a vertical marker line on a point on the X axis to denote a cut-off point. Is there a way to do this in the chart script given that the cut-off point is not known until runtime. I can retrieve it from a global variable.

Re: Dynamically add a marker line to a chart [message #726125 is a reply to message #725746] Fri, 16 September 2011 16:03 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

Here is an example that sets the location based on a parameter.

Jason

On 9/15/2011 12:29 PM, Mike Wulkan wrote:
> Hi,
>
> I have a Chart with bar series. I would like place a vertical marker
> line on a point on the X axis to denote a cut-off point. Is there a way
> to do this in the chart script given that the cut-off point is not known
> until runtime. I can retrieve it from a global variable.
>
>
Re: Dynamically add a marker line to a chart [message #726177 is a reply to message #726125] Fri, 16 September 2011 18:10 Go to previous messageGo to next message
Mike Wulkan is currently offline Mike WulkanFriend
Messages: 147
Registered: July 2009
Senior Member
Thanks for this Jason. One problem though. In my chart I have a bunch of series but only one data value per series. The marker I'd like to insert is between to series bars not between two groups of series. Is this possible?
Re: Dynamically add a marker line to a chart [message #726777 is a reply to message #726177] Mon, 19 September 2011 14:36 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

Mike,

Can you take a screenshot of where the marker line is, and use paint to
show where you want it?

Jason

On 9/16/2011 2:10 PM, Mike Wulkan wrote:
> Thanks for this Jason. One problem though. In my chart I have a bunch of
> series but only one data value per series. The marker I'd like to insert
> is between to series bars not between two groups of series. Is this
> possible?
Re: Dynamically add a marker line to a chart [message #727099 is a reply to message #726777] Tue, 20 September 2011 12:14 Go to previous messageGo to next message
Mike Wulkan is currently offline Mike WulkanFriend
Messages: 147
Registered: July 2009
Senior Member
index.php/fa/4007/0/

The green line is where the marker line comes out but the red line is where I want it. The problem is that all the bars are from different series and there is only one row so the x axis only has one point on it.
Re: Dynamically add a marker line to a chart [message #727170 is a reply to message #727099] Tue, 20 September 2011 14:52 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

Mike,

Add the following beforeDrawMarkerLine script:

function beforeDrawMarkerLine( axis, markerLine, icsc )
{
importPackage(Packages.org.eclipse.birt.chart.model.component.impl);
importPackage(Packages.org.eclipse.birt.chart.model.data.impl);
importPackage(Packages.org.eclipse.birt.chart.model.attribute);
importPackage(Packages.org.eclipse.birt.chart.model.attribute.impl);
importPackage(Packages.org.eclipse.birt.chart.util);
markerLine.setValue(NumberDataElementImpl.create(0.5));

}

On 9/20/2011 8:14 AM, Mike Wulkan wrote:
> The green line is where the marker line comes out but the red line is where I want it. The problem is that all the bars are from different series and there is only one row so the x axis only has one point on it.
Re: Dynamically add a marker line to a chart [message #727479 is a reply to message #727170] Wed, 21 September 2011 12:15 Go to previous messageGo to next message
Mike Wulkan is currently offline Mike WulkanFriend
Messages: 147
Registered: July 2009
Senior Member
Hi Jason,

Doh! For some reason my mind was stuck on integral values... this was just too easy. Well actually it was too easy. In actual fact I don't want the marker line at the halfway point. I'd like to place it on the right edge of the 2nd bar (as shown by the arrow). I'm not sure how to calculate this offset and tie it to the number of bars. I tried multiples of 6 (number of bars) and multiples of 7 (number of edges). The image shown is 3*(1/7) but as you can see it places the marker a little too far to the right. Is there an easy formula I can use or do I just have to fudge it and hardcode a value that works?
index.php/fa/4016/0/
Re: Dynamically add a marker line to a chart [message #727633 is a reply to message #727479] Wed, 21 September 2011 17:54 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

That is a bit more complicated. Look at the attached example.

Jason

On 9/21/2011 8:15 AM, Mike Wulkan wrote:
> Hi Jason,
>
> Doh! For some reason my mind was stuck on integral values... this was just too easy. Well actually it was too easy. In actual fact I don't want the marker line at the halfway point. I'd like to place it on the right edge of the 2nd bar (as shown by the arrow). I'm not sure how to calculate this offset and tie it to the number of bars. I tried multiples of 6 (number of bars) and multiples of 7 (number of edges). The image shown is 3*(1/7) but as you can see it places the marker a little too far to the right. Is there an easy formula I can use or do I just have to fudge it and hardcode a value that works?
>
Re: Dynamically add a marker line to a chart [message #728077 is a reply to message #727633] Thu, 22 September 2011 13:50 Go to previous messageGo to next message
Mike Wulkan is currently offline Mike WulkanFriend
Messages: 147
Registered: July 2009
Senior Member
Hi Jason,

I think this is getting closer but my chart is configured a little differently and the code you supplied doesn't appear to calculate the correct positions. I have included a sample chart with the configuration that I am using and the arrow points to where I would like the marker line to be positioned. The actual marker line is where the current code puts it.

index.php/fa/4033/0/
Re: Dynamically add a marker line to a chart [message #728216 is a reply to message #728077] Thu, 22 September 2011 18:12 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

Can you lower the unit spacing (which is getting added per series).
See modified example.

Jason

On 9/22/2011 9:50 AM, Mike Wulkan wrote:
> Hi Jason,
>
> I think this is getting closer but my chart is configured a little differently and the code you supplied doesn't appear to calculate the correct positions. I have included a sample chart with the configuration that I am using and the arrow points to where I would like the marker line to be positioned. The actual marker line is where the current code puts it.
>
>
  • Attachment: MikeW.zip
    (Size: 6.15KB, Downloaded 274 times)
Re: Dynamically add a marker line to a chart [message #728527 is a reply to message #728216] Fri, 23 September 2011 12:32 Go to previous messageGo to next message
Mike Wulkan is currently offline Mike WulkanFriend
Messages: 147
Registered: July 2009
Senior Member
Hi Jason,

This almost works. The example works but when I applied this code to my actual chart the line was still out (to the right). So I went back and forth a million times to try to figure out what the difference was. I finally figured it out that it was the legend. In my actual chart code I had different place holder names for each of the series which I subsequently modified in my beforeDrawLegendItem script. One of the place holder names was long (eg., "Brobdingnagian"). The chart formatted based on the width of the legend as it was specified in the designer. At runtime the width of the legend was actually smaller which threw out the calculations for the marker.

I have worked around this by changing the place holder names to something shorter since they don't actually display anyway, but for future reference, I was wondering if there was still a minor tweak to the code that would account for this?
Re: Dynamically add a marker line to a chart [message #728654 is a reply to message #728527] Fri, 23 September 2011 15:35 Go to previous message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

Mike,

You can get the size of any the chart blocks (plot, legend, title etc)
but I am not certain how you would do the calculation.

Jason

On 9/23/2011 8:32 AM, Mike Wulkan wrote:
> Hi Jason,
>
> This almost works. The example works but when I applied this code to my
> actual chart the line was still out (to the right). So I went back and
> forth a million times to try to figure out what the difference was. I
> finally figured it out that it was the legend. In my actual chart code I
> had different place holder names for each of the series which I
> subsequently modified in my beforeDrawLegendItem script. One of the
> place holder names was long (eg., "Brobdingnagian"). The chart formatted
> based on the width of the legend as it was specified in the designer. At
> runtime the width of the legend was actually smaller which threw out the
> calculations for the marker.
>
> I have worked around this by changing the place holder names to
> something shorter since they don't actually display anyway, but for
> future reference, I was wondering if there was still a minor tweak to
> the code that would account for this?
Previous Topic:Which Version Of RAD and WAS supports BIRT 3.7 ?
Next Topic:Why aren't all the data set columns in the 'Available Column Bindings' list?
Goto Forum:
  


Current Time: Thu Apr 18 07:56:49 GMT 2024

Powered by FUDForum. Page generated in 0.02186 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top