Was there a final resolution to this? I'd appreciate a solution to be able 
to customize color for each cell in a Timeline chart.  Thanks

On Saturday, April 18, 2015 at 10:18:33 AM UTC-7, rashmani wrote:
>
> Hi there,
>
> I have a problem with custom coloring each bar in a timeline chart.
> I'm building two arrays in PHP like this, for column (bar) values and bar 
> colors:
>             // holds column headers and values
>             $tl_series[] = array(
>                 array('type'=>'string', 'id'=>'Date'),
>                 array('type'=>'string', 'id'=>'Value'),
>                 array('type'=>'date', 'id'=>'Start'),
>                 array('type'=>'date', 'id'=>'End'),
>                 );
>             // holds bar colors
>             $tlc_series = array();
>
> Then I'm adding value columns like this:
>             foreach ($timeline as $tl_date) {
>                 ....
>                 $tl_series[] = array($tl_label, $value, $startdate, 
> $enddate);
>                 $tlc_series[] = <customized_color_hex_value>;
>             }
>
> The column values array is then json encoded and passed to a scripted 
> javascript function that builds the chart, like this:
>             function drawChart' . $chart_id . '() {
>                 var data = google.visualization.arrayToDataTable(' . 
> CJavaScript::jsonEncode($tl_series) . ');
>             ...
>
> Finally, I use the $tlc_series colors array as value for timeline's colors 
> option:
>             ...
>             'colors' => CJavaScript::jsonEncode($tlc_series),
>             ...
>
> I have varying number of values, from 2 up to 40, grouped by label and 
> distributed between two dates (for those wondering, if any, I'm using YII 
> to programmatically get data from MYSQL and draw charts).
>
> Obviously if I have N values, $tl_series will have N+1 elements while 
> tlc_series color array will have N elements.
> In my thinking, element $tlc_series[0] should hold color for element 
> $tl_series[1].
> But I'm wrong: not even a simple two values array looks fine.
> What should I do? I tried adding a dummy first element to colors array, 
> without success.
> Is the value array somehow reordered when passed to arrayToDataTable or to 
> the chart?
> How can I keep value and color arrays synchronized?
>
> Thanks for any suggestion or idea,
> rash*
>
>
>

-- 
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/google-visualization-api.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-visualization-api/33895f1a-9606-4bca-8ea7-d3fc9966782d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to