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)
y-Axis Label using two dataset
Chintan
Hi all
I would like to make my y-Axis label name dynamic.
I have single procedure that returns the Integer number for y axis. and i would like to give label using another dataset in same report.
Here attached report y axis has number 7,8,9,10. i have another dataset which has map value of 7 is ABC, 8 is XYZ and so on....
Please help me..
Thanks in advance.....
Chintan
Find more posts tagged with
Comments
mwilliams
You could join the dataSets and use the joint dataSet for the chart. Another option would possibly be to assign persistentGlobalVariables the alternate values for your integers and name them using the integer field. This way, in your chart script, you can recall the PGV by the integer value in the label and replace it with the PGV's value. The best option is probably the joint dataSet though. Hope this makes sense.
Chintan
Hello Michael,
Thanks for reply.
I think it would be helpful for me.
But as i am new to write script.
Can you suggest me how to write script...
i have GradeId like 1,2,3 and so on....
and gradeMap like abc,xyz,pqr and so on....
so how can i write that PGV?
Or if you have any document which will helpful for me for reference then it would be good for me.
Thanks..
Chintan
mwilliams
What is your BIRT version?
Chintan
I am using BIRT version 2.6
mwilliams
Take a look at this example. Be sure to change the flat file location in the dataSource before running.
Chintan
Thank you so much Michael,
Thats what i am looking for.
But here i am not able to map it using GUI tools.
I changed source path and etc in "XML Source", and its working but
I tried to find both file relation using Layout -> Edit Chart -> Select Data ???? not able to find its relationship. Can you guide me please.
Once again thank you somuch for your prompt reply
Regards
Chintan
mwilliams
You'll have to do the replacing in script, like I did in the example. I don't think you'll be able to do this on the select data tab of the chart editor.
Chintan
Thanks michael.<br />
<br />
One more question.<br />
Shall i use more then one PersistentGlobalVariable?<br />
If i would like same thing for series label.<br />
<br />
Is it possible?<br />
<br />
I used Number 1 with <strong class='bbc'>PersistentGlobalVariable</strong> function and its working fine for y axis label....<br />
1
<br />
function beforeDrawAxisLabel( axis, label, icsc )<br />
{<br />
if (! axis.isCategoryAxis()){<br />
temp = icsc.getExternalContext().getScriptable().getPersistentGlobalVariable(label.getCaption().getValue());<br />
if (label.getCaption().getValue() == 0){<br />
label.getCaption().setValue("");<br />
}<br />
else{<br />
label.getCaption().setValue(temp);<br />
}<br />
}<br />
}<br />
End 1
<br />
<br />
Shall i use another <strong class='bbc'>PersistentGlobalVariable</strong> for number 2 function??<br />
<br />
2
<br />
<br />
<br />
function beforeDrawLegendItem( lerh, bounds, icsc )<br />
{ <br />
temp = icsc.getExternalContext().getScriptable().getPersistentGlobalVariable(lerh.getLabel().getCaption().getValue());<br />
if (lerh.getLabel().getCaption().getValue() == "41"){<br />
lerh.getLabel().getCaption().setValue("Hi"); <br />
}<br />
else<br />
{ <br />
lerh.getLabel().getCaption().setValue(temp);<br />
}<br />
}<br />
End 2
<br />
<br />
Here i attached my chart how it looks like.
mwilliams
You're actually using many PGVs already. You're setting one for each axis label. So, the way to do it would be to set PGV's for your series values and then recall them in your legend script.
Chintan
As i add the below code for grade name like p1, p2, ... and so on...
<structure name="cachedMetaData">
<list-property name="resultSet">
<structure>
<property name="position">1</property>
<property name="name">grade_id</property>
<property name="dataType">integer</property>
</structure>
<structure>
<property name="position">2</property>
<property name="name">grade</property>
<property name="dataType">string</property>
</structure>
</list-property>
</structure>
<method name="onFetch"><![CDATA[reportContext.setPersistentGlobalVariable(row["grade_id"].toString(),row["grade"]);]]></method>
<property name="dataSource">Data Source</property>
<list-property name="resultSet">
<structure>
<property name="position">1</property>
<property name="name">grade_id</property>
<property name="nativeName">grade_id</property>
<property name="dataType">integer</property>
<property name="nativeDataType">4</property>
</structure>
<structure>
<property name="position">2</property>
<property name="name">grade</property>
<property name="nativeName">grade</property>
<property name="dataType">string</property>
<property name="nativeDataType">12</property>
</structure>
</list-property>
<text id="1638">
<property name="dataSet">Map Data Set3</property>
<list-property name="visibility">
<structure>
<property name="format">all</property>
<expression name="valueExpr" type="javascript">true</expression>
</structure>
</list-property>
<list-property name="boundDataColumns">
<structure>
<property name="name">grade_id</property>
<expression name="expression" type="javascript">dataSetRow["grade_id"]</expression>
<property name="dataType">integer</property>
</structure>
<structure>
<property name="name">grade</property>
<expression name="expression" type="javascript">dataSetRow["grade"]</expression>
<property name="dataType">string</property>
</structure>
</list-property>
<property name="contentType">auto</property>
<text-property name="content"><![CDATA[Hidden text box tied to "key" dataSet so that it is ran first to set PGV's.]]></text-property>
</text>
====================== END
Then shall i use same for series???
like
Below should be like that?
<structure name="cachedMetaData">
<list-property name="resultSet">
<structure>
<property name="position">1</property>
<property name="name">subject_id</property>
<property name="dataType">integer</property>
</structure>
<structure>
<property name="position">2</property>
<property name="name">subject</property>
<property name="dataType">string</property>
</structure>
</list-property>
</structure>
<method name="onFetch"><![CDATA[reportContext.setPersistentGlobalVariable(row["subject_id"].toString(),row["subject"]);]]></method>
<property name="dataSource">Data Source</property>
<list-property name="resultSet">
<structure>
<property name="position">1</property>
<property name="name">subject_id</property>
<property name="nativeName">subject_id</property>
<property name="dataType">integer</property>
<property name="nativeDataType">4</property>
</structure>
<structure>
<property name="position">2</property>
<property name="name">subject</property>
<property name="nativeName">subject</property>
<property name="dataType">string</property>
<property name="nativeDataType">12</property>
</structure>
</list-property>
<text id="1639">
<property name="dataSet">Map Data Set4</property>
<list-property name="visibility">
<structure>
<property name="format">all</property>
<expression name="valueExpr" type="javascript">true</expression>
</structure>
</list-property>
<list-property name="boundDataColumns">
<structure>
<property name="name">Subject_id</property>
<expression name="expression" type="javascript">dataSetRow["Subject_id"]</expression>
<property name="dataType">integer</property>
</structure>
<structure>
<property name="name">subject</property>
<expression name="expression" type="javascript">dataSetRow["subject"]</expression>
<property name="dataType">string</property>
</structure>
</list-property>
<property name="contentType">auto</property>
<text-property name="content"><![CDATA[Hidden text box tied to "key" dataSet so that it is ran first to set PGV's.]]></text-property>
</text>
Chintan
Hello Michael,
Here i send you the attached code with same example you send me before,just added things only is subject.cvs file, but when i used it with PGV it overwrite id with value..
Means i have key is 1 to 9 and its value like p0,p1,... ,p9 in once CVS
and another cvs has value start from 8,9,...to 20 and its value like maths, science, ... in another CVS.
i used PGV, but it over wrire values like 1 to 7 takes as p0 to p8 and 8 and 9 takes as maths and science.. as you can see in example in below image.
In below image i want P1 to P9 on x axis and series should be subject name, not in x axis.
Currently is shows 8 and 9 in x axis. and series with blue color "9" should be science, red color "10" should be maths and so on...
Waiting for your kind reply
mwilliams
Ok, I wasn't thinking that you series values were the same as the values on the y-axis. Take a look at this modified version of your report. I changed the report name, but the csv files are the same. In the dataSet for the legend, I changed the name of the PGV to have "legend" in the name. Then, in the chart script, I added the function that is required to change the name of the legend labels and recalled the PGV with the current label value plus the word "legend". Let me know if you have questions.
Chintan
Thank you so much michael.
mwilliams
Not a problem. Glad to help! Let us know whenever you have questions!
Chintan
Hi Michael,<br />
<br />
Here i required your help again.<br />
<br />
I have 2 reports.<br />
As in First report you can see in it that was showing name "Student name" on x-axis using student_id PGV.<br />
<br />
and second report is(StudentDetail.rptdesign) on click of that student name the detail information of student should come.<br />
Thats my requirement.<br />
<br />
Here what i am doing is <br />
Step 1 : Edit Chart -> Format Chart -> Click on Interactivity<br />
Step 2 : Axis Interactivity -> Add Hyperlink <br />
Step 3 : Hyperlink Editor -> Click Edit Base URL<br />
Step 4 : Select Hyperlink type (Where i select Drill-Through) <br />
a -> Select Target Report(Where i select Report Design and select my DetailReport"StudentDetail.rptdesign")<br />
i Think on click that the Report parameter <strong class='bbc'>should come Automatically</strong> but it isnt, all thaug i enter parameters: Student_id values : row["student_id"]<br />
b -> Select a target Anchor (Remains blank)<br />
c -> Create a link expression that matches the target bookmark<br />
Link Expression :row["student_id"]<br />
d -> Remaining thigs are as it is.<br />
<br />
<br />
Even all the stpes i am not able to map actual student id. Report working on Click Student Name it shows student details but not the proper one.<br />
<br />
Please help me.<br />
<br />
Thanks<br />
Chintan
mwilliams
Are you doing the interactivity button on the value-y-series tab or on the x-axis tab? If doing the x-axis, I don't believe there is access to the chart data. You'll need to do the link on the value series instead. Let me know. If you attach the report, I might be able to be more exact with what to do.
On the parameter not showing up. Does the report you're linking to have a report parameter that accepts the parameter you want to pass?
Chintan
Hello Michael,
Thanks for the reply, but i am not getting your points what you exactly want to say.
Here i am sending you attached Report.
Where one is master report on that x axis there are student Name.
On click that I need to show the student details but for only one student.
I tried but not getting for single student, please have a look attched reports and let me know.
Thanks in advance.
And also let me know, Shall i click on Bars and get detail reports?
If yes, how would be it possible.
Regards
Chintan
mwilliams
Sorry. Yes, I meant to put the drill through on the bars instead. To do this, you'd select the value (y) series section in the chart editor and click on the interactivity button. Then you'll be able to do your drill through and grab the axis value to pass as your parameter. Let me know if you have questions!
Chintan
Hello Michael,
Here i attached image, may it helps you togo thru my problem.
Here you can see in attached image that i click on Value (Y) Series - > Click Interactivity -> Open Series Interctivity(Add URL) -> Open Hyperlink Editor(Before click on Edit base URl i give category series, value series and name "student_id") -> click on Edit base URL it open Hyperlink Opetions -> but on selection of Report design it doesnt show me Report parameters to link...
Can you help me ....How it can possible.
Click on bar.. it should pass student id...
Thanks in advance..
mwilliams
Did you click on the drop down under "parameters"?
Chintan
It doesnt show anything under "parameters"
mwilliams
Can you attach your main and drill through reports so I can see your setup. Thanks.
Chintan
Hello michael,
Attached file has 2 reports.
One is chart and second is details.
As per you told me on y series value i add hyperlink but it doesnt show any parameters.
Have a look into it and pls help me.
Thanks
mwilliams
You need to add a report parameter to the drill through report for there to be a parameter in your drill through drop down. Take a look at the modified reports.
Chintan
Thanks you so much michael.
You make my weekend superb...
mwilliams
Ha. You're welcome. Glad I could help your weekend!
Chintan
Hello Michael,
for y axis label we are using -> "beforeDrawAxisLabel" script
to change y series label lagent -> "beforeDrawLegendItem" script
to change x series label which script i have to use?
Can you have any URL that give me information that to do this this, i can use the given script or like that?
Please guide me if you have.
Thanks
chintan
mwilliams
To change the x-axis label in your chart, you'd also use the "beforeDrawAxisLabel", you'd just access the category axis rather than the y-series axis. Let me know if you need more detail than this!
Chintan
IN that case Either i can change x axis label or y axis label not both of them at same time.
function beforeDrawAxisLabel( axis, label, icsc )
{
if (! axis.isCategoryAxis()){
temp = icsc.getExternalContext().getScriptable().getPersistentGlobalVariable(label.getCaption().getValue());
if (label.getCaption().getValue() == 0){
label.getCaption().setValue("0");
}
else{
label.getCaption().setValue(temp);
}
}
// ADDED CODE TO CHANGE X AXIS LABEL NAME
temp1 = icsc.getExternalContext().getScriptable().getPersistentGlobalVariable(label.getCaption().getValue()+ "sname".toString());
label.getCaption().setValue(temp1);
}
Here in above script i just added additional code to change x axis label and i can change only x axis name not y axis label.
mwilliams
So, you have it working how you want now?