Dynamic Chart Markers
Hi,
i want to generate a chart with markers on the x-axis and the x-axis is of type text.
i try it with this script:
function beforeGeneration(chart, 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);
var chart = icsc.getChartInstance();
var yAxis = chart.getAxes().get(0).getAssociatedAxes().get(0);
var EoD = icsc.getExternalContext().getScriptable().getParameterValue("EoD");
top_ml = MarkerLineImpl.create(yAxis, NumberDataElementImpl.create(EoD));
top_ml.getLabel().getCaption().setValue("EoD " + EoD);
top_ml.getLineAttributes().getColor().set(0,200,0);
top_ml.getLineAttributes().setStyle(LineStyle.SOLID_LITERAL);
top_ml.getLineAttributes().setThickness(2);
}
But how can i change the axis? and does this also work for text axis?
thx
i want to generate a chart with markers on the x-axis and the x-axis is of type text.
i try it with this script:
function beforeGeneration(chart, 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);
var chart = icsc.getChartInstance();
var yAxis = chart.getAxes().get(0).getAssociatedAxes().get(0);
var EoD = icsc.getExternalContext().getScriptable().getParameterValue("EoD");
top_ml = MarkerLineImpl.create(yAxis, NumberDataElementImpl.create(EoD));
top_ml.getLabel().getCaption().setValue("EoD " + EoD);
top_ml.getLineAttributes().getColor().set(0,200,0);
top_ml.getLineAttributes().setStyle(LineStyle.SOLID_LITERAL);
top_ml.getLineAttributes().setThickness(2);
}
But how can i change the axis? and does this also work for text axis?
thx
0
Comments
-
Can you explain a little more about what you're trying to do? What are the axis values? What is the value of the parameter? One of the axis values? I'm not sure if it can be done, but if you answer the questions above, or just recreate the issue with the sample database, I'll take a look.Warning No formatter is installed for the format ipb0
-
hi,
i want to create a dynamic marker on the x-axis:
function beforeGeneration(chart, 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);
var chart = icsc.getChartInstance();
var xAxis = chart.getAxes().get(0);
var EoD = icsc.getExternalContext().getScriptable().getParameterValue("EoD");
top_ml = MarkerLineImpl.create(xAxis, NumberDataElementImpl.create(EoD));
top_ml.getLabel().getCaption().setValue("EoD " + EoD);
top_ml.getLineAttributes().getColor().set(0,200,0);
top_ml.getLineAttributes().setStyle(LineStyle.SOLID_LITERAL);
top_ml.getLineAttributes().setThickness(2);
}
the x-axis is generated out of "to_char(mydate, 'YYYY-WW')"
the paramter has data type string and is a text box.
thx for your help.0 -
hmmm<br />
<br />
now i changed my statement to get a date for the x-axis, he sorts the line chart correct. <br />
But when i want to add a dynamic marker via:<br />
intcountformaker = 0;<br />
<br />
function afterDataSetFilled( series, dataSet, icsc )<br />
{<br />
importPackage(Packages.org.eclipse.birt.chart.model.attribute.impl); <br />
importPackage(Packages.com.ibm.icu.util);<br />
//x-axis Series<br />
if (series.eClass().getName().equals("Series")) <br />
{ <br />
var list = dataSet.getValues();<br />
<br />
for ( i=0; i<list.length; i=i+1)<br />
{<br />
var cdt = icsc.getExternalContext().getScriptable().getParameterValue("EoD");<br />
<br />
var yr = list.fieldDifference( cdt, Calendar.YEAR );<br />
var mn = list.fieldDifference( cdt, Calendar.MONTH );<br />
var dy = list.fieldDifference( cdt, Calendar.DATE );<br />
if( yr == 0 && mn == 0 && dy == 0){<br />
intcountformaker = i;<br />
}<br />
}<br />
}<br />
}<br />
<br />
function beforeGeneration( chart, icsc )<br />
{<br />
importPackage(Packages.org.eclipse.birt.chart.model.component.impl);<br />
importPackage(Packages.org.eclipse.birt.chart.model.data.impl);<br />
importPackage(Packages.org.eclipse.birt.chart.model.attribute);<br />
importPackage(Packages.org.eclipse.birt.chart.model.attribute.impl);<br />
var xAxis =chart.getAxes().get(0);<br />
<br />
target_ml = MarkerLineImpl.create(xAxis, NumberDataElementImpl.create(intcountformaker));<br />
//target_ml.getLabel().getCaption().setValue("EoD");<br />
target_ml.getLineAttributes().getColor().set(32,145,245);<br />
}<br />
he changed the dates of the x-axis to my EoD parameter - i have no idea why...0 -
now i try this:
function beforeGeneration( chart, 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);
var xAxis =chart.getAxes().get(0);
var EoD = icsc.getExternalContext().getScriptable().getParameterValue("EoD");
target_ml = MarkerLineImpl.create(xAxis, NumberDataElementImpl.create(EoD));
target_ml.getLabel().getCaption().setValue("EoD");
target_ml.getLineAttributes().getColor().set(32,145,245);
}
but also failed
any ideas how i cant create a dynamic marker on the x-axis for datetimes?
thx0 -
Take a look at this report. I am not using the x-axis as a category axis in this example. It is an actual dateTime axis. All I did was add a marker line in the chart wizard, then since it was my only marker line, I only needed a very simple script to change the value to the entered parameter value. Let me know if this is not what you're wanting. If you're using a category axis, it'll be different.Warning No formatter is installed for the format ipb0
-
importPackage (Packages.org.eclipse.birt.chart.model.data.impl);
function beforeDrawMarkerLine( axis, markerLine, icsc )
{
if (markerLine.getLabel().getCaption().getValue() == "EoD") {
if (icsc.getExternalContext().getScriptable().getParameterValue("EoD") != null) {
ml = icsc.getExternalContext().getScriptable().getParameterValue("EoD");
y = ml.getYear() + 1900;
m = ml.getMonth();
d = ml.getDate();
markerLine.setValue(DateTimeDataElementImpl.create(new Date(y,m,d)));
}
else {
markerLine.getLineAttributes().setVisible(false);
markerLine.getLabel().setVisible(false);
}
}
if (markerLine.getLabel().getCaption().getValue() == "Frozen"){
if (icsc.getExternalContext().getScriptable().getParameterValue("Frozen") != null) {
ml = icsc.getExternalContext().getScriptable().getParameterValue("Frozen");
y = ml.getYear() + 1900;
m = ml.getMonth();
d = ml.getDate();
markerLine.setValue(DateTimeDataElementImpl.create(new Date(y,m,d)));
}
else {
markerLine.getLineAttributes().setVisible(false);
markerLine.getLabel().setVisible(false);
}
}
}
But what do you mean with: category axis, it'll be different.0 -
Well, when it's a category axis, the marker value accepts an integer. From what I saw, when I was creating the example above, the value is for which tick on the x-axis will get the marker line, so you won't be able to pass a date for this, you'll have to figure out based on the date entered by the user how many ticks over you want the marker line to be. That's just what I assumed based on what I saw before switching to a non-category axis. I could be very wrong on that. I'll edit the above example to use a category axis and see how it goes.Warning No formatter is installed for the format ipb0
-
Ok. Take a look at this one. The first chart is the same as the one from the example above. The second chart is with a category axis. Same explanation as above, I added the marker in the wizard and just change the value in script. I elected to do all of my script in the chart, but I'm sure you could figure out the position for the marker outside and pass it in. Maybe easier than what I had to do, in the end.Warning No formatter is installed for the format ipb0
-
one more question
Is it possible via birt to create a dynamic xAxis? (scalable)
i try something like this only as example for the yAxis (which is a number):
function beforeGeneration( chart, icsc )
{
min = NumberDataElementImpl.create(100.0);
yAxis1 = chart.primaryBaseAxes[0];
yScale1 = yAxis1.getScale();
yScale1.setMin(min);
}
but it didnt work0 -
Sorry for the delay. Take a look at this devShare post:
http://www.birt-exchange.org/org/devshare/designing-birt-reports/830-setting-the-min-and-max-value-of-the-xaxis-with-scripting/Warning No formatter is installed for the format ipb0
Categories
- All Categories
- 107 Developer Announcements
- 53 Articles
- 104 General Questions
- 141 IM Services
- 43 OpenText Hackathon
- 32 Developer Tools
- 20.6K Analytics
- 4.1K AppWorks
- 8.9K Extended ECM
- 898 Cloud Fax and Notifications
- 76 Digital Asset Management
- 9.3K Documentum
- 29 eDOCS
- 118 Exstream
- 39.8K TeamSite
- 1.7K Web Experience Management