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)
Dynamic Marker Range
aaraya
Hi,
how to create dynamic marker range from dataset ?
mi table is
value | min | avg | max
1.2 | 1 | 1.5 | 2
1.05 | 1 | 1.5 | 2
1.3 | 1 | 1.5 | 2
i need 3 marker range ,
1 - start 0 - end 1
2 - start 1 - end 1.5
3 - start 1.5 - end 2
I have tried the next, but only generates 1 range marker
function beforeDrawMarkerRange( axis, markerRange, icsc )
{
importPackage( Packages.org.eclipse.birt.chart.model.data.impl );
markerRange.setEndValue(NumberDataElementImpl.create(100))
markerRange.setStartValue(NumberDataElementImpl.create(10))
}
Tranks for your help.
Find more posts tagged with
Comments
mwilliams
If you pass your values from your dataSet to your chart through global variables, this will work to create and set the values for the 3 ranges.<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
function beforeGeneration( chart, icsc )
{
importPackage(Packages.org.eclipse.birt.chart.model.component.impl);
importPackage(Packages.org.eclipse.birt.chart.model.attribute.impl);
importPackage(Packages.org.eclipse.birt.chart.model.data.impl);
min = NumberDataElementImpl.create(parseFloat(icsc.getExternalContext().getScriptable().getGlobalVariable("min")));
avg = NumberDataElementImpl.create(parseFloat(icsc.getExternalContext().getScriptable().getGlobalVariable("avg")));
max = NumberDataElementImpl.create(parseFloat(icsc.getExternalContext().getScriptable().getGlobalVariable("max")));
zero = NumberDataElementImpl.create(0)
yAxis = chart.getAxes()[0].getAssociatedAxes()[0];
markerRange1 = MarkerRangeImpl.create(yAxis,zero,min,ColorDefinitionImpl.RED());
markerRange2 = MarkerRangeImpl.create(yAxis,min,avg,ColorDefinitionImpl.YELLOW());
markerRange3 = MarkerRangeImpl.create(yAxis,avg,max,ColorDefinitionImpl.GREEN());
}
</pre>
<br />
Hope this helps.
SamuelB
<p>My implementation of this does not produce three ranges. Only marketRange3 render. If I comment out that line, then markerRange2 show up. I I comment out both the create of markerRange2 and markerRange3, then markerRange1 shows up.</p>
<p>Hmm..</p>
SamuelB
<p>Just in case someone else has the same problem...</p>
<p>You cannot overlap the threshold values. Also if you add marker range labels, you may have to control the order of creation.</p>
<div>zero = NumberDataElementImpl.create(0);</div>
<div>mina = NumberDataElementImpl.create(39);</div>
<div>minb = NumberDataElementImpl.create(41);</div>
<div>avga = NumberDataElementImpl.create(99);</div>
<div>avgb = NumberDataElementImpl.create(100);</div>
<div>max = NumberDataElementImpl.create(200);</div>
<div> </div>
<div> </div>
<div>yAxis = chart.getAxes()[0].getAssociatedAxes()[0];</div>
<div>markerRange3 = MarkerRangeImpl.create(yAxis,avgb,max,ColorDefinitionImpl.GREEN());</div>
<div>markerRange2 = MarkerRangeImpl.create(yAxis,minb,avga,ColorDefinitionImpl.YELLOW());</div>
<div>markerRange1 = MarkerRangeImpl.create(yAxis,zero,mina,ColorDefinitionImpl.RED());</div>
<div>markerRange1.getLabel().getCaption().setValue("Range 1");</div>
<div>markerRange2.getLabel().getCaption().setValue("Range 2");</div>
<div>markerRange3.getLabel().getCaption().setValue("Range 3");</div>
mwilliams
Sorry for the delay. Glad you figured it out. Thanks for updating the thread.