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)
Using Chart Script to Define a specific bar color
Philippe J
<div>Hi,</div><div>I want to create a Bar Chart with a different color for each bar in the same serie:</div><div>My Data set give 3 informations: X_value, Y_value and X_color.</div><div>In a table, no problem to catch the color information and change the background color, but in the bar chart ?</div><div>I think that the solution is in the function beforeDrawDataPoint, so i've start the script in the report design enclosed.</div><div>
Find more posts tagged with
Comments
pricher
<p>Hi,</p><p> </p><p>In chart scripting, you don't have access to the data set. Therefore, you need to store the color information in a persistent global variable <strong>before </strong>you start generating the chart.</p><p> </p><p>I have modified your report design and made the following changes:</p><p>- put the table before the chart so I can store the values of "X_Color" in a global persistent variable on each iteration of the detail row. Look at the onCreate event for the script;</p><p>- in the chart script, I have added a beforeGeneration method to read back the values of the X_color stored in the global persistent array;</p><p>- in your original BeforeDataPoint script, I use the index value of the series to update the background color.</p><p> </p><p>You may need to change the code for your requirements, but the bottom line is that when scripting a chart, you don't have access to the data set!</p><p> </p><p>Hope this helps,</p><p> </p><p>P.</p>
micajblock
<p>Also here</p><p> </p><p><a data-ipb='nomediaparse' href='
http://developer.actuate.com/community/forum/index.php?/files/file/1056-chart-colors-based-on-data/'>http://developer.actuate.com/community/forum/index.php?/files/file/1056-chart-colors-based-on-data/</a></p>
;
Philippe J
<div>Hi,</div><div> </div><div>Thank you, this is exactly what I was looking.</div><div> </div><div>But I have another problem: My report shows several charts based on a parameter that changes in the dataset for each graph.</div><div>So I would like to clear, in the example, the array "myArray" between the charts. But in which function must I implement this reset ?</div><div> </div><div>Philippe</div>
micajblock
<p>Sorry, I do not understand the requirement. You have multiple charts each chart will have different colors?</p>
Philippe J
<p>Yes, for each graph: the color of each bar changes based on the result of a SQL query that is regenerated.</p>
micajblock
<p>Curious as to why you are doing this. From a pure visualization perspective, this is bad practice. Bar charts with a single series should use the same color. Different colors usually mean a different series. At least would have different meanings. </p><p> </p><p>That being said can you provide sample data in a CSV file. I will look in to building an example.</p>