From 5fd77a3b050c97e6cd3a3edda79c7af26b692dcf Mon Sep 17 00:00:00 2001 From: Bruno Massa <brmassa@67164.no-reply.drupal.org> Date: Fri, 15 May 2009 04:48:24 +0000 Subject: [PATCH] New features: * Google's Scatter plot now accepts individual point labels --- google_charts/google_charts.inc | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/google_charts/google_charts.inc b/google_charts/google_charts.inc index 6d90f6e..300ccd0 100644 --- a/google_charts/google_charts.inc +++ b/google_charts/google_charts.inc @@ -146,10 +146,6 @@ function _google_charts_series(&$chart, &$data) { $chart_data .= ','; } - if ($data['#type'] == 'pie2D' and !empty($series)) { - - } - // Get only the numeric values from the series $series_data = _charts_series_values($data[$series]); @@ -161,16 +157,25 @@ function _google_charts_series(&$chart, &$data) { // For each series of data, scan it foreach (array_keys($series_data) as $value) { + $svalue = &$data[$series][$value]; $chart_data .= _google_charts_data_codingsimple($series_data[$value], $max); - $value_labels_temp[] = empty($data[$series][$value]['#label']) ? NULL : $data[$series][$value]['#label']; + $value_labels_temp[] = empty($svalue['#label']) ? NULL : $svalue['#label']; - if ($options['value_attributes']) { - // Series legends - $legends[] = empty($data[$series][$value]['#label']) ? NULL : $data[$series][$value]['#label']; + // Get the highlight points + if (!empty($svalue['#highlight']) + or ($data['#type'] == 'scatter' and ($series % 2 == 0))) { + $highlight[] = 't'. $svalue['#label'] .','. + (empty($svalue['#color']) ? substr($data[$series]['#color'], 1) : substr($svalue['#color'], 1)) .','. + $series .','. + $value .','. + (empty($svalue['#size']) ? 10 : $svalue['#size']); + } - // Series colors - $colors[] = empty($data[$series][$value]['#color']) ? NULL : substr($data[$series][$value]['#color'], 1); + if ($options['value_attributes'] + or ($data['#type'] == 'scatter' and ($series % 2 == 0))) { + // Series legends + $value_labels[] = empty($svalue['#label']) ? NULL : $svalue['#label']; } } @@ -196,7 +201,7 @@ function _google_charts_series(&$chart, &$data) { // Insert data $chart[] = 'chd=s:'. $chart_data; - // Insert series legend + // Insert series color if (!empty($colors)) { $chart[] = 'chco='. implode(',', $colors); } @@ -206,10 +211,16 @@ function _google_charts_series(&$chart, &$data) { $chart[] = 'chl='. implode('|', $value_labels); } + // Insert multiple series tag if ($options['legend'] and !empty($legends)) { $chart[] = 'chdl='. implode('|', $legends); } + // Insert values labels + if (!empty($highlight)) { + $chart[] = 'chm='. implode('|', $highlight); + } + return; } -- GitLab