Home
Analytics
Chart scripting
Fuigi
<p>Hi it's me again..</p>
<p> </p>
<p>I have a report with parameter and with a list with the name of entity, when I click on the name of entity that open another report with the same parameter, and another (the of entity was click before).<br><br>
In the do report I have 4 chart. On these chart I can have negative or positive number (depends the parameter choice). If I leash the default min and max, if the number are positive the min is the min of my number. But I want 0 as min. And if I write 0 in min, for my negative value is horrible, i can't see them. How do this with script ?</p>
<p> </p>
<p>I try to create a min in my data set, but when I try to take this value in my script that write "Row not assigned". So I try to create a variable, but I don't know how take the min with variable and how use variable in script.</p>
<p> </p>
<p>In my graph I have another problem, when the min is 0 and I have a value with 0 the label of my value is just between the label of my X axis. How resolve that ?</p>
Find more posts tagged with
Comments
mwilliams
Could you provide an example (using the sample database) showing your issue? Screenshots would be helpful, too in understanding what you're seeing. Thanks!
Fuigi
<p>Hi,</p>
<p> </p>
<p>I give you what I have now and what I want.</p>
<p> </p>
<p>I success to have min "0" creating new serie with expression "0" and not visible in the graph. I have a min with 0 on my graph but the space between my bars is reduced. I give you what I success to create too. (min0 and min0bis)</p>
mwilliams
Okay. I see what you're saying, now, I think.<br><br>To set the scale value in your chart to the appropriate value, you'd simply need to process your dataset in the afterDataSetFilled script. If there is a value less than 0, let BIRT handle the scale. If there isn't, explicitly set the min axis value to 0.<br><br>For the 0 labels, you'd just need to change the insets on the label if the label value is 0. You'd do this in the beforeDrawDataPointLabel chart script.<br><br>Let me know if I'm misunderstanding anything.<br><br>I have done an example of both of these before. I'll see if I can find them. If I cannot find them and you'd like an example made, let me know your BIRT version. I'll make an example in your version.
mwilliams
Take a look at this thread for the conditional check on setting the yaxis min:<br><br><a data-ipb='nomediaparse' href='
http://developer.actuate.com/community/forum/index.php?/topic/23856-chart-force-the-x-axis-to-start-at-y0/'>http://developer.actuate.com/community/forum/index.php?/topic/23856-chart-force-the-x-axis-to-start-at-y0/</a>
;
Fuigi
<p>I will be grateful if you can give me an example, I'm not at ease with script. I don't really understand how coding.<br><br>
I use the latest version of birt, 4.4.2. With Eclipse version for Java EE IDE developer, windows 7 32 bits. (I don't know if it's important to specify) </p>
Fuigi
<p>Thank for your rapid answer !</p>
<p> </p>
<p>I will look that in deep. And try.</p>
mwilliams
Sounds good. Let me know if you have questions about it.
Fuigi
<p>Hi.<br>
</p>
<p>I have some question.</p>
<p> </p>
<p>In your example you have this code</p>
<pre class="_prettyXprint _lang-js">
function beforeGeneration(chart, icsc)
{
importPackage( Packages.org.eclipse.birt.chart.model.data.impl );
xAxis = chart.getBaseAxes()[0];
scale = xAxis.getScale();
scale.setStep (35);
xAxis.setScale(scale);
yAxis = chart.getOrthogonalAxes( xAxis, true)[0]
yscale = yAxis.getScale();
if(!anyNegatives){
if(icsc.getExternalContext().getScriptable().getGlobalVariable("setOriginTo_0"))
yscale.setMin( NumberDataElementImpl.create(0));
}
//yscale.setStep (10);
//minseries =icsc.getExternalContext().getScriptable().getGlobalVariable("minseries");
//maxseries =icsc.getExternalContext().getScriptable().getGlobalVariable("maxseries");
//yscale.setMin( NumberDataElementImpl.create(minseries) )
//yscale.setMax( NumberDataElementImpl.create(maxseries) )
//yAxis.setScale(yscale);
}
</pre>
<p>I don't understand the 2 if. The first " if (!anyNegatives) "</p>
<p>What that mean ?</p>
<p>Same question for the second if, and in the second if you use a variable no ? But in the report I don't see any variable created. What this variable refere to ? (except var anyNegatives = false;)</p>
<p> </p>
<p>The afterDataSetFilled is execute before the beforeGeneration ?</p>
<p> </p>
<p>And at last, have you example for the 0 label scripting ?</p>
<p> </p>
Fuigi
<p>A last question to be sure.</p>
<p> </p>
<p>What compose the var "temp" ? Only the column is use in the chart ? (My column "Quantity")</p>
<p>Or all column ? Like Quantity, SumQuantity etc.. ?</p>
mwilliams
anyNegatives is probably a value set to true/false in the afterDataSetFilled script.<br><br>What is the code where temp is set? Which of the examples are you looking at so I can be sure to look at the same one.
Fuigi
<p>I'm looking that example.</p>
mwilliams
temp is defined as dataSet.getValues(); It's a listing of the values in the series. anyNegatives is also defined in the same place (chart script AfterDataSetFilled function - be sure to scroll down in the chart script to see). The beforeGeneration is called after the AfterDataSetFilled script, so the values are set, then accessed in beforeGeneration.<br><br>Hope this helps.
Fuigi
<p>Thank for your reply !</p>
mwilliams
You're welcome!