Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » BIRT » Chart with 2 y-axis series - problem sorting
Chart with 2 y-axis series - problem sorting [message #1009592] Fri, 15 February 2013 11:01 Go to next message
Mimmo Rossi is currently offline Mimmo RossiFriend
Messages: 146
Registered: February 2013
Senior Member
Hi all,
i have this problem: i have a chart with 2 series of y-axis, i would that these series have two different sorting of data, that is to say that the first series have the axis order from 0 to 9 (for example) and the second from 9 to 0.
It's possible?
Thanks in advance
Re: Chart with 2 y-axis series - problem sorting [message #1009876 is a reply to message #1009592] Fri, 15 February 2013 22:55 Go to previous messageGo to next message
Michael Williams is currently offline Michael WilliamsFriend
Messages: 1925
Registered: July 2009
Senior Member

So, two different axes and one goes from 0 to 9 and the other from 9 to 0? Not just two series on an axis? To do this, you'd need to reverse the values in the series associated with the axis you want to reverse and then simply replace the y-axis label values to be in the reverse order. For example, if you had values 1, 3, and 7 on the reversed axis, you would actually need to make them 8, 6, and 2. These values would plot normally, but when you change the axis labels, they would appear as if they were the original values on a reversed axis. Hope this makes sense. Let me know if you need an example.

Michael

Developer Evangelist, Silanis
Re: Chart with 2 y-axis series - problem sorting [message #1010242 is a reply to message #1009876] Sun, 17 February 2013 00:36 Go to previous messageGo to next message
Mimmo Rossi is currently offline Mimmo RossiFriend
Messages: 146
Registered: February 2013
Senior Member
Hi,
yes if it's possible i need an example because i don't understand how reverse the value in the report (labels are dynamic, not fixed)
In the image there is my case:
http://dl.dropbox.com/u/47586998/img.JPG
What I want is that the series on the left have the value reversed (and consequently also the line).
Thanks
Re: Chart with 2 y-axis series - problem sorting [message #1010268 is a reply to message #1010242] Sun, 17 February 2013 02:08 Go to previous messageGo to next message
David Good is currently offline David GoodFriend
Messages: 41
Registered: September 2012
Member
HI Mimmo,

The following is the code I used to reverse a secondary y-axis from 0-5 to 5-0 and their associated values. I created it using a single y-axis example provided by Jason Weathersby (http://birtworld.blogspot.com.au/2008/12/birt-reversing-chart-scale.html).

My code will need to be modified in your case (i.e. series name), but should help.

David

//Global scale, this is set for the secondary Y-axis.
//I am modifying it to list in reverse order (i.e. 5 at the bottom)
gblscale =5;


//*** this is the first event called for charting
//So set scale here
function beforeDataSetFilled( series, idsp, icsc )
{
// We can also link to a report param so users can adjust the scale at will
gblscale = 5; // icsc.getExternalContext().getScriptable().getParameterValue("Scale");
}

function afterDataSetFilled(series, dataSet, icsc)
{
// Change the data set values to new values.
// i.e. a 2 becomes a 3 so it plots higher on chart, but we set labels to display 2, tricking the chart.
// In chart builder, the series names of the series are the identifiers
if( series.getSeriesIdentifier() == "Capacity"){
var list = dataSet.getValues();
for ( i=0; i < list.length; i=i+1)
{
list[i] = gblscale - list[i];
}
}
}

function beforeGeneration(chart, icsc)
{
importPackage( Packages.org.eclipse.birt.chart.model.data.impl );
xAxis = chart.getBaseAxes()[0];
//Select the 2nd Y-axis from axis array
// for 1st Y-axis use: yAxis = chart.getOrthogonalAxes( xAxis, true)[0]
yAxis = chart.getOrthogonalAxes( xAxis, true)[1]
yscale = yAxis.getScale();
yscale.setStep (1); // Set the axis step interval here
// this sets default min/max - we over ride next function
yscale.setMin( NumberDataElementImpl.create(0) )
yscale.setMax( NumberDataElementImpl.create(gblscale) )
yAxis.setScale(yscale);

}

function beforeDrawAxisLabel(axis, label, icsc)
{
importPackage(Packages.org.eclipse.birt.chart.model.attribute);
if (axis.getType() == AxisType.LINEAR_LITERAL){
// this condition only for Y-axis' (LINEAR_LATERAL)
// only override the non-primary Y-axis
if (!axis.isPrimaryAxis()) {
var val = parseFloat(label.getCaption().getValue());
var newval = gblscale - val;
label.getCaption().setValue(newval);
}
}
}

function beforeDrawDataPointLabel(dph, label, icsc)
{
// get the series name
var currSeriesName = dph.getSeriesValue();
//only change data poiint labels for the 'flipped' secondary Y-axis
if (currSeriesName == "Capacity") {
var val = parseFloat(label.getCaption().getValue());
var newval = gblscale - val;
newval = newval.toFixed(0); // select decimal places in data point labels
label.getCaption().setValue(newval);
}
}
Re: Chart with 2 y-axis series - problem sorting [message #1010865 is a reply to message #1010268] Mon, 18 February 2013 11:14 Go to previous messageGo to next message
Mimmo Rossi is currently offline Mimmo RossiFriend
Messages: 146
Registered: February 2013
Senior Member
Hi David,
thanks for you help; there is some adjustment to do but it's a good start for my case. I'll let you know if it is positive or if i had other problems.
Thanks a lot.
icon14.gif  Re: Chart with 2 y-axis series - problem sorting [message #1010928 is a reply to message #1010865] Mon, 18 February 2013 13:47 Go to previous messageGo to next message
Mimmo Rossi is currently offline Mimmo RossiFriend
Messages: 146
Registered: February 2013
Senior Member
Very Happy
it works fine
Thanks a lot
Re: Chart with 2 y-axis series - problem sorting [message #1011001 is a reply to message #1010928] Mon, 18 February 2013 16:22 Go to previous messageGo to next message
Mimmo Rossi is currently offline Mimmo RossiFriend
Messages: 146
Registered: February 2013
Senior Member
Hi David,
there is a "little" problem, on onmouseover marker of series lines the tooltip shown is with old value, can i set correct value? Otherwise i disable onmouseover event.
Thanks
Re: Chart with 2 y-axis series - problem sorting [message #1011018 is a reply to message #1011001] Mon, 18 February 2013 17:19 Go to previous messageGo to next message
Mimmo Rossi is currently offline Mimmo RossiFriend
Messages: 146
Registered: February 2013
Senior Member
Mimmo Rossi wrote on Mon, 18 February 2013 11:22
Hi David,
there is a "little" problem, on onmouseover marker of series lines the tooltip shown is with old value, can i set correct value? Otherwise i disable onmouseover event.
Thanks

i have solved in this way:
function beforeDrawDataPoint( dph, fill, icsc ){
	var currSeriesName = dph.getSeriesValue();
	if (currSeriesName == <nameSeriesToInvert>) {
		var val = parseFloat(dph.getOrthogonalDisplayValue());
		var newval = gblscale - val;
		newval = newval.toFixed(0);
		dph.setOrthogonalValue(newval);
	}		
}

Is the correct approach?
Re: Chart with 2 y-axis series - problem sorting [message #1692164 is a reply to message #1011018] Tue, 14 April 2015 05:45 Go to previous messageGo to next message
kshirod mishra is currently offline kshirod mishraFriend
Messages: 50
Registered: March 2015
Member
Hi David/Mimmo,

I am having one problem not exactly the same as Mimmo was facing. I have two Y-series. In two series , i have used two filters for series Y1 and Y2 respectively. But real problem is for my series 2 i.e Y2 -axis, there is no data is coming in the preview after putting filter on my Dataset. How i have approached to solve this issue has been attached in the trail mail for your quick refereces. Hope you can understand everything from the screen shot. I need urgent help for this issue which will be grateful to you.

Thanks & Regards:
kshirod Mishra
Re: Chart with 2 y-axis series - problem sorting [message #1692222 is a reply to message #1009592] Tue, 14 April 2015 11:38 Go to previous messageGo to next message
kshirod mishra is currently offline kshirod mishraFriend
Messages: 50
Registered: March 2015
Member
Hi Mimmo,

Thanks for your quick response.
1. Whether your issue has been resolved?
2. If still not yet resolved, please create a BUG.
3. If your issue has been resolved, please guide me how to solve this issue. I will be very much thankful to you.

Thanks $ Regards:
kshirod Mishra
Re: Chart with 2 y-axis series - problem sorting [message #1692382 is a reply to message #1009592] Wed, 15 April 2015 12:16 Go to previous message
kshirod mishra is currently offline kshirod mishraFriend
Messages: 50
Registered: March 2015
Member
Hi Mimmo Rossi,

Could you please help me how to use multi filters for multi Y series?

Thanks $ Regards:
kshirod Mishra
Previous Topic:Eclipse BIRT vs Actuate Birt Designer Pro
Next Topic:Datasource with Teradata
Goto Forum:
  


Current Time: Thu Apr 25 06:50:20 GMT 2024

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

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

Back to the top