Charts: different bar color for correct or incorrect status

37 views
Skip to first unread message

Ignacio Castañeira

unread,
Feb 15, 2017, 4:16:43 AM2/15/17
to Google Visualization API
Hi, all!

My intention is to draw a bar chart that will show information about a program execution.

The bar height itself will show the execution duration in seconds (vAxis), but I'd like the bar color to show the executions status (eg. red for failed execution, blue for correct execution)

var data = new google.visualization.arrayToDataTable([
            ["Date", "Status", "Duration (s)"],
            ["13/02/2017 13:42:58", 0, 29],
            ["13/02/2017 16:53:07", 1, 41],
            ["13/02/2017 16:54:36", 0, 26]
            ]);


Status 0 is correct, 1 is failed execution.

I've been checking the forum but I couldn't find any meaningful info. Is there a way to do what I want? Perhaps an if/else block in the "colors" array from options??

Thanks in advance for your answers! Best regards!

Daniel LaLiberte

unread,
Feb 15, 2017, 8:44:11 AM2/15/17
to Google Visualization API
You can use different series to associate with different colors (which means instead of your status column, you would put the duration value in one of two columns, one for failed and one for correct).

Or you can replace your status column with a 'style' role column that you put after your duration column.  This will let you specify the color of each bar.  See https://developers.google.com/chart/interactive/docs/roles

--
You received this message because you are subscribed to the Google Groups "Google Visualization API" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-visualization-api+unsub...@googlegroups.com.
To post to this group, send email to google-visualization-api@googlegroups.com.
Visit this group at https://groups.google.com/group/google-visualization-api.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-visualization-api/813f1a4c-4b00-4063-956f-480647f10234%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Reply all
Reply to author
Forward
0 new messages