How define a background color?

wflorian - December 5, 2008 - 19:58
Project:Chart API
Version:5.x-1.2
Component:Miscellaneous
Category:task
Priority:critical
Assigned:Unassigned
Status:active
Description

I did leave the global background color field empty, because I need a pie chart and a bar chart with different background colors. But how can I manually set a background color for every chart?

'#chart_fill' => chart_fill('c', '000000'),

This doesn't work for the whole background when using for bar chart. For the pie chart this code doesn't work at all.

So how can I set a seperate background color for every chart??

Thank you.

Florian

#1

tjholowaychuk - December 5, 2008 - 20:35

Hmm chart fill shoooould work.. BUT tthat being said I may have done crappy validation on wither or not the global bg was set, meaning "" may be set if I did not properly check things. You might want to try variable_del to remove it preceding your other code.

#2

wflorian - December 6, 2008 - 08:01

thanks for your answer. but what do you mean with "variable_del"? how should I implement this? how should I use this?

here is my current code:

$chart = array(
'#chart_id' => 'test_chart',
'#type' => CHART_TYPE_BAR_H,
'#size' => chart_size(274, 65),
'#bar_size' => chart_bar_size(30, 5),
'#chart_fill' => chart_fill('c', 'ff0000'),
);
   
$chart['#data']['benutzt'] = array(10);
$chart['#data']['ungenutzt'] = array(90);
 
$chart['#data_colors']['benutzt'] = '4a7e00';
$chart['#data_colors']['ungenutzt'] = 'e5eac0';

$chart['#mixed_axis_labels'][CHART_AXIS_X_BOTTOM][1][] = chart_mixed_axis_label('0%');
$chart['#mixed_axis_labels'][CHART_AXIS_X_BOTTOM][1][] = chart_mixed_axis_label('25%');
$chart['#mixed_axis_labels'][CHART_AXIS_X_BOTTOM][1][] = chart_mixed_axis_label('50%');
$chart['#mixed_axis_labels'][CHART_AXIS_X_BOTTOM][1][] = chart_mixed_axis_label('75%'); 
$chart['#mixed_axis_labels'][CHART_AXIS_X_BOTTOM][1][] = chart_mixed_axis_label('100%');

echo chart_render($chart);

this is how it looks: http://img149.imageshack.us/img149/6620/unbenannt1nf7.gif

do you see what I mean? I do need the whole background in the chart_fill color. right now only the inner part of the background gets the chart_fill color. the rest is white, when no global background color is entered.

when I use the global setting for background color, the chart fill color will be ignored and the whole background will be filled with the global background color. But I do need to set different background colors to different charts, so the global setting doesn't work for me.

Any solution? Any Patch to specify a background color for a chart id? I would really appreciate your help.

Thank you.

Florian

#3

wflorian - December 6, 2008 - 08:27

here we go.

i looked at the google api settings:

'#chart_fill' => chart_fill('bg', 'ff0000'), this is your friend!;)

 
 

Drupal is a registered trademark of Dries Buytaert.