Posted by alpapan on September 5, 2009 at 3:59pm
| Project: | Charts |
| Version: | 6.x-1.x-dev |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | needs review |
| Issue tags: | charts, max bug, open flash chart, patch |
Issue Summary
Hello
Here are some personal fixes and additions for the openflash module.
* when trying to create multiple charts, the max is preserved as it is set as global.
* I recommend set the maximum as max + 5% of the maximum value
* added a couple more attributes for the graph
Comments/additions ?
thanks
alexie
function _openflashchart_chart(&$chart, &$data) {
if ($data['#title-size']){
$chart->set_title($data['#title'],'{font-size: '.$data['#title-size'].'px;}');
}
else {
$chart->set_title($data['#title'],'{font-size: 20px;}');
}
// fixes recommended by other posts in the issue queue
$chart->set_width($data['#width']);
$chart->set_height($data['#height']);
$chart->set_bg_colour($data['#color']);
}
function _openflashchart_series_generic(&$chart, &$data, $series) {
// when no series are requested, remove global as it causes to preserve the maximum with multiple
if (!empty($series)){static $max;}
// Get only the numeric values from the series
$series_data = _charts_series_values($data[$series]);
$chart->set_data($series_data);
// Get the highest value on the series add 5%, to be a reference point
$max = $max < max($series_data) ? max($series_data) : $max;
$max=$max+($max/20);
// Y labels
$chart->set_y_max($max);
// X labels
// specify steps
if (!empty($data['#x-steps'])){
$chart->set_x_axis_steps($data['#x-steps']);
}
$value_labels = array();
$toogle = FALSE;
foreach (array_keys($series_data) as $value) {
if (empty($data[$series][$value]['#label'])) {
$value_labels[] = '';
}
else {
$value_labels[] = $data[$series][$value]['#label'];
$toogle = TRUE;
}
}
if (!empty($toogle) && empty($data['#no-x-labels'])){
$chart->set_x_labels($value_labels);
// the following allows to hide the axis labels by setting them to the same color as the background
if (!empty($data['#no-x-axis-labels'])){
$chart->set_x_label_style(0,$data['#color']);
}
}
if (!empty($data['#x-legend'])){
$chart->set_x_legend($data['#x-legend'],10);
}
}
Comments
#1
There is nothing to review here. It would be great if you could turn this proposed change into a patch so others could review it.
Thanks!
#2
Subscribe
Currently the graph (lines) sticks on the above end of the graphic...this does not look very nice..
#3
Sorry been stupidly busy and I only learned how to create patches after this issue was created.
attached.
thanks
alexie
#4
thanks alapagan
why you change background color code?
when i apply this patch , it seems bug still exists because at top of chart max number is not shown properly
i add an empty title (with one space character) then top offset becomes right
i make another patch with base of your idea and these changes
#5
>why you change background color code?
I think because I wanted the option to hide the X axis labels too.
#6
Y-Axis ignored negative values, so I added a couple of lines to take this into consideration.
Attached is my openflashchart.inc with this code plus changes from the patch above.