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)
How to create a pie chart when the data set does not returns values in the proper way
frenchGuy
Hi,
I have a data set that returns the following columns and values :
Network Equipment | time OK | time CRITICAL | time UNKNOWN
switch1 | 22 hours| 2 hours | 0
I would like to present the time OK, time CRITICAL and time UNKNOWN in a pie chart for my network equipment. It's easy to create a pie chart when the data set is formated like this :
Network Equipment | status | time
switch1 | OK | 22 hours
switch1 | CRITICAL| 2 hours
switch1 | UNKNOWN | 0
But how can I do to display a pie chart in my case? The data set retrieves the columns and the values with a SQL query from a MySQL database table.
Thanks for your help!
Find more posts tagged with
Comments
johnw
Without getting into chart scripting or anything fancy like that, the easiest way is to use a scripted data source, and create rows based off the columns. So in the open event, you'd do something like set a count variable to 0. Then in the fetch, your just pull values from a global variable, increment the counter, and do this until you reach your column count. You know you have 3 columns, (Uptime, Critical, Unknown), so the statement would look something like:
if (cnt == 0)
return (reportContext.getGlobalVariable("uptime"));
if (cnt == 1)
return (reportContext.getGlobalVariable("critical"));
Then, you just assign those global variables in the onFetch event for the main query. The great thing is if you have multiple rows from the main query, it won't matter. You could even just pass in parameters to do this if you don't want to use global variables.
John
Hans_vd
Maybe I'm missing something but can't you just change the SQL into something like this:<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>SELECT network_equipment,
time_ok
FROM your_table
UNION
SELECT network_equipment,
time_critical
FROM your_table
UNION
SELECT network_equipment,
time_unknown
FROM your_table</pre>
frenchGuy
<blockquote class='ipsBlockquote' data-author="'Hans_vd'" data-cid="68795" data-time="1285570005" data-date="26 September 2010 - 11:46 PM"><p>
Maybe I'm missing something but can't you just change the SQL into something like this:<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>SELECT network_equipment,
time_ok
FROM your_table
UNION
SELECT network_equipment,
time_critical
FROM your_table
UNION
SELECT network_equipment,
time_unknown
FROM your_table</pre></p></blockquote>
<br />
Yes you're right! That's exactly what I wanted to do!<br />
<br />
Thanks
Hans_vd
Glad I could help