Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
THRUST SERVICES & TOOLS
CLOUD EDITIONS
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
change pallete color based on column not used in chart
Arif shah
Hello,<br />
<br />
If I want to change the color of circles in scatter chart based on a field not being used in the chart, then how do i use that column in script. I mean how can i get the that data...for example <br />
<br />
If (row[v_count])>2<br />
fill red color...<br />
<br />
The exact code is below<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
function beforeDrawDataPoint(dph, fill, icsc)
{
//Fill implements Fill interface
//ImageImpl
//ColorDefinitionImpl
//GradientImpl
//MultipleFillImpl
//EmbeddedImageImpl
//PatternImageImpl
importPackage( Packages.org.eclipse.birt.chart.model.attribute.impl );
val = dph.getOrthogonalValue();
if( fill.getClass().isAssignableFrom(ColorDefinitionImpl)){
if (row[v_count]>2){
fill.set(255, 0, 0);
}
}
}
</pre>
<br />
but i dont know do i get that v_count column in the script. is there some function to get that column ?<br />
<br />
I mean if we are making some calculations based on a column from databinding columns..that is not being used in x or y axis, then how do we access that column in the script..is there some kind of function for that.. I tried row["v_count"], but it is not working. <br />
<br />
Arif
Find more posts tagged with
Comments
mwilliams
You can store the value in a persistent global variable outside the chart and access the persistent global variable inside the chart's script.
Arif shah
<blockquote class='ipsBlockquote' data-author="'mwilliams'" data-cid="86837" data-time="1322837303" data-date="02 December 2011 - 07:48 AM"><p>
You can store the value in a persistent global variable outside the chart and access the persistent global variable inside the chart's script.<br /></p></blockquote>
<br />
Hello,<br />
<br />
Thanks for the response. I have another question. If I pass the vehiclecount as an array from hidden table, then how do i know which row is against which x axis and y axis value. Are you suggesting that i should be taking all the data from the hidden table instead of the current dataset of the chart?<br />
<br />
Arif
Arif shah
<blockquote class='ipsBlockquote' data-author="'mwilliams'" data-cid="86837" data-time="1322837303" data-date="02 December 2011 - 07:48 AM"><p>
You can store the value in a persistent global variable outside the chart and access the persistent global variable inside the chart's script.<br /></p></blockquote>
<br />
Hello,<br />
<br />
I can access the variable inside the chart, but how can i know against which x axis and y axis , we have to compare this specific value. Jason had mentioned to pass a map to this chart and use the x axis and y axis as an index. Can you please tell me how can i use the map inside chart to change the color of the data points based on another value<br />
<br />
Br,<br />
<br />
Arif
mwilliams
Arif,
The way you showed me you were doing it in our chat, you're going to end up only passing the last row. You could either use your data to create unique persistent global variable names that can be recalled by your chart data or like Jason said, you could pass an array or map that stores all of the values and then use that object in your script to find your value to set your color. As we discussed, please create a small sample report and a csv file of your data for the data that I can use to show you one or both ways. Thanks!
mwilliams
Here is the design you sent me with script added to change the color of the marker in the plot based on the criteria you told me. You'll find the only script in the onCreate of the detail row of the chart and in the chart script. To do this same thing with arrays, you'd simply create your array or map while in the onCreate of the detail row, then pass your object through a PGV in onCreate of the footer of the table.
Hope this helps.
Arif shah
<blockquote class='ipsBlockquote' data-author="'mwilliams'" data-cid="89656" data-time="1323105242" data-date="05 December 2011 - 10:14 AM"><p>
Here is the design you sent me with script added to change the color of the marker in the plot based on the criteria you told me. You'll find the only script in the onCreate of the detail row of the chart and in the chart script. To do this same thing with arrays, you'd simply create your array or map while in the onCreate of the detail row, then pass your object through a PGV in onCreate of the footer of the table.<br />
<br />
Hope this helps.<br /></p></blockquote>
<br />
Thanks Williams,<br />
<br />
I am facing another issue. When i try to change to datasource back to SQL connection, the report stops working. The only change that i can see is the order of columns in dataset and dataypes of columns. In the CSV files, all types are strings, but in SQL, placemark id is integer and count is decimal. Does that make any difference? <br />
<br />
Arif
Arif shah
<blockquote class='ipsBlockquote' data-author="'Arif shah'" data-cid="89708" data-time="1323132378" data-date="05 December 2011 - 05:46 PM"><p>
Thanks Williams,<br />
<br />
I am facing another issue. When i try to change to datasource back to SQL connection, the report stops working. The only change that i can see is the order of columns in dataset and dataypes of columns. In the CSV files, all types are strings, but in SQL, placemark id is integer and count is decimal. Does that make any difference? <br />
<br />
Arif<br /></p></blockquote>
<br />
okay, I found the reason. I had to convert the counts into string and then it started working. <br />
<br />
Arif
mwilliams
Great! Glad it's working! Let us know whenever you have questions!
Arif shah
<blockquote class='ipsBlockquote' data-author="'mwilliams'" data-cid="91039" data-time="1323374200" data-date="08 December 2011 - 12:56 PM"><p>
Great! Glad it's working! Let us know whenever you have questions!
<br /></p></blockquote>
<br />
Hello,<br />
<br />
I want a small modification in this chart. I am currently grouping by placemark_id (as you can see in the chart). by default, all the ids will appear in the legend, if you will make the legend visible. However, I want to over ride that legend. I want to show in the legend that<br />
<br />
Red means 0 vehicles<br />
yellow means 1 Vehicle <br />
green means more than 1 vehciles<br />
<br />
How can i modify the chart for the legend change<br />
<br />
Thanks<br />
Arif
mwilliams
One thing you could do is just make the chart legend NOT visible and create your own legend outside the chart that shows what you want to show. Using the chart legend is possible, but in your case, with only 3 colors, it would be very simple to create your own legend.
Let me know.
Arif shah
<blockquote class='ipsBlockquote' data-author="'mwilliams'" data-cid="91453" data-time="1323706440" data-date="12 December 2011 - 09:14 AM"><p>
One thing you could do is just make the chart legend NOT visible and create your own legend outside the chart that shows what you want to show. Using the chart legend is possible, but in your case, with only 3 colors, it would be very simple to create your own legend.<br />
<br />
Let me know.<br /></p></blockquote>
<br />
you mean writing hard coded text outside chart in text objects? and if i had to do it in chart, how would i do it. Yes, this is a simple case, but incase i want it dynamic..(the number of legend series is different than what is inside the grouping columns). In simple words, if i had to do it inside chart legend, how would i do it?<br />
<br />
Arif
mwilliams
Sorry for the delay. If you do it within the current legend, you'll have to modify the fill colors and legend label text for all the labels. Would need to make sure there were already enough legend items available to change, as well. Dynamically outside the chart, you could use a list or table to do this.