Pie Charts label size feature

Alpha42 - June 19, 2008 - 16:21
Project:Open Flash Chart API
Version:6.x-2.10
Component:Code
Category:support request
Priority:normal
Assigned:Unassigned
Status:active
Description

I'm tinkering a bit with all of the various drupal charting modules right now, and well, to be honest, Open flash chart seems to be the way to go.. :)

A huge part of my needs is going to be regurgitating various data in charts that look alot a like, so I decided to whip up little wrappers for my own use (yes, I know, a wrappers, around your API.. the levels of fun..)

Anyway, I have something such as:

function my_util_chart_pie($opts){
// My wrapper, function to make line charts a bit easier to manage in code..
// Build an array (passed here as $opts), containing all the various data/title/labels/etc
// and this does the rest.

$g = new open_flash_chart_api();
$g->set_title($opts['#title'], '{font-size: 14px; color: #ffffff}' );
if ($opts['#width']){ $g->set_width($opts['#width']); } else { $g->set_width(400); }
if ($opts['#height']){ $g->set_height($opts['#height']); } else { $g->set_height(200); }
$g->set_bg_colour('#2b477c');
$g->pie(75,'#ffffff','#6699cc');
$g->pie_values($opts['#values'],$opts['#labels'],$opts['#links']);
$g->pie_slice_colours($opts['#colors']);

return $g->render();
}

I've already done a few bar charts using a similar function, and that one works great. The problem I have with pie charts is, I cant seem to figure out how to set the font size for the labels that are passed as part of $g->pie_values. My pie charts all have very little teeny tiny labels in black text. :(

Attached is an example. The labels ("Past Due" and "Open") are there, but veeeery small and black.. I can't figure out how to change that (adjusting the size of the graph makes no difference).

I'm assuming there's a way to do this, but I'm not finding it in any of the documention, and the open flash docs just confuse me further when I try to look to them for guidance... :)

#1

Alpha42 - June 19, 2008 - 16:22

Gah, I forgot to attach. :)

AttachmentSize
piechart.gif 3.57 KB

#2

redndahead - June 19, 2008 - 16:41

On line 25 of the module see if this fixes it.

$this->title_style = '{font-size:20px;}';

There's a missing brace at the end of the font-size value.

#3

Alpha42 - June 19, 2008 - 17:08

No love, changed line 25 of open_flash_chart_api.module to:

$this->title_style = '{font-size:20px;}';

and same effect. :(

#4

redndahead - June 19, 2008 - 18:22

Ok on line 826 is the function for the pie chart. It doesn't work. You need to replace the function with this one.

function pie($alpha, $line_colour, $label_colour = '#000000', $fontsize = 14){
$this->pie = $alpha .','. $line_colour .',{font-size: '. $fontsize . 'px; color: '. $label_colour .'}';
}

Then your call to the pie should work the same.

I'll attach a patch to this issue and probably commit it if you verify it's working for you.

red

#5

Alpha42 - June 19, 2008 - 19:02

replacing function pie as shown in #4 seems to have done it for me. ;) Many thanks!

#6

redndahead - June 19, 2008 - 19:41

attaching patches.

AttachmentSize
pie5.patch 1.59 KB

#7

redndahead - June 19, 2008 - 19:46

Well looks like for some reason the d6 patch won't attach. argh look at the d5 and figure it out.

#8

redndahead - June 19, 2008 - 19:47
Status:active» fixed

#9

redndahead - June 19, 2008 - 19:48
Component:Documentation» Code
Category:support request» bug report

#10

Anonymous (not verified) - July 3, 2008 - 19:54
Status:fixed» closed

Automatically closed -- issue fixed for two weeks with no activity.

#11

ionmedia - April 17, 2009 - 15:31
Title:Pie Charts: No font size setting for labels?» Pie Charts label size feature
Version:6.x-2.6» 6.x-2.10
Category:bug report» support request
Status:closed» active

patch works fine in d6

but how we can separetly change whis value in each pie chart, builded from view chart's function ?

 
 

Drupal is a registered trademark of Dries Buytaert.