FlashChartHelper - version 3
3 : Api
Public variables
$swf
Path relative to webroot to the swf file
example: $flashChart->swf = 'flash/ofc.swf'; // app/webroot/flash/ofc.swf
$ready
The javascript/flash integration in the vendors include two custom callbacks. This is one and it will be run when the flash is ready.
example: $flashChart->ready = 'alert('ready');';
$loading
The other javascript callback. Called once for each chart.
example: $flashChart->loading = 'alert('loading chart');';
$data
The dataset(s) should be set through the setData method and only handled directly in extreme cases.
$Chart
Contains the Chart vendor object. May (and should only) be used directly to control something that the helper doesn't implement.
Private variable - default values
There are several private variables that define default behavior in the top of the helper. If you wish, you may alter the helper to work by default more close to your specifications. Most of these are styles. At the moment they are set up for the charts to blend into Cake's default style.
Public methods
begin($options = array())
Initializes the helper and embeds the needed javascript libraries. You should start with this method and the only available option key at the moment is 'prototype' (set it to true to be compatible).
setData($data, $numbersPath = '{n}', $labelsPath = false, $datasetName = 'default', $chartId = 'default')
Always call this at least once and do so between begin() and axis(). This method sends the data the helper and, optionally, where in the dataset it can find the values and labels (if any). Also note that
if you wish to use several datasets, use the last parameter to give each set a name that can be used by later methods to distinguish between the sets.
render($width = null, $height = null, $chartId = 'default', $domId = false)
Outputs the embeded flash, rendering the charts. When multiple charts are used use the chartId parameter. If you wish to place the chart somewhere else than where this method is rendered, you may use the $domId parameter to target a specific dom object (place div with this id somewhere in your page).
chart($type = 'bar', $options = array(), $datasetName = 'default')
Renders the javascript with data and customization for one graph chart. To be called last, but may be called multiple times with different datasetNames for different datasets or different type (and options) for different display of the same data in the same chart.
What options are valid vary from chart type to chart type, and the helper is set up in such a way as to pass the options on to the vendor, therefore letting you use an updated vendor without changes to the helper. This also means that the helper doesnt know (or care) what options you send, but if they do not exist in the vendor, you will throw an error. Check http://teethgrinder.co.uk/open-flash-chart-2/ under the type you are using for what options may be set.
chart() aliases
The following methods are aliases for FlashChartHelper::chart(), that implement the custom chart types. They may be called directly, or for consistency, you can only use chart('type').
- barStack($options = array(), $datasetName = 'default')
- scatter($options = array(), $datasetName = 'default')
- sketch($options = array(), $datasetName = 'default')
- radar($options = array(), $datasetName = 'default')
- pie($options = array(), $datasetName = 'default')
setToolTip($tooltip = '', $options = array())
Sets the tool tip for the chart by using a string with replaceable codewords like #val#. Check OFC2 for documentation. Also you can style the tooltips look and behavior using the options parameter.
setTitle($title_text, $style = '')
Sets the title above the chart. You can also style it with css as the second parameter.
setLegend($axis, $title, $style = '')
Set the descriptive texts next to the axies to describe their meaning. You can also style it directly here using CSS.
axis($axis, $options = array())
Use this method to set up the axis' range and labels. There are also a number of options (mostly styling) that can be set up. The two axis have different options, but a full documentation can be found on the links given under. Importantly though, the y has a range option that takes an array with 3 values (minimum value, max value and step size). On the x axis you will often want to use the labels from the dataset and the helper will add those labels if you have defined a proper labels path, either as the third parameter of setDate() or using the setLabelsPat() method. Note, that even if you require no options for the x-axis, you will have to call this method on that axis for it to use those labels. Also you may set the 'vertical' option to true to have the x-axis labels be rendered sideways (vertically).
rightAxis($options = array())
When using multiple charts in one diagram, it may be useful to have a second y-axis for different values. At the moment this feature is not perfectly implemented in the vendor, among other problems, all charts will use the left y-axis' range for displaying their values.
setRadarAxis($options = array(), $labels = array())
Radar charts are circular and this method sets the grid options, more than an axis really. The options it takes in define the "height" and steps of the grid and its colour. You can also set the labels for the y axis (or what you can think of as the radius).
setRadarSpokes($spokes, $colour = null)
Spokes are the labels that name the "radius"-axis of the chart.
setNumbersPath($path, $datasetName = 'default')
Tells the helper where to find the numbers to generate the graph with. This is the same functionality as the 2nd paramter of the setData() method. You do not need to set it both places.
setLabelsPath($path)
Tells the helper where to find the labels for the X axis. This is the same functionality as the third paramter of the setData() method. You do not need to set it both places.
NB!. The path should start with the name of the dataset (ie. $flashChart->setLabelsPath('Default.{n}.User.name');).
setBgColour($colour)
Set the background color for the entire diagram. Optional. Will use the default stored in FlashChart::bg_colour if not used.
setStackColours($colours = array())
For the chart type Bar_stack this method sets the colours of the bars.
Comments
Question
1 thanks
Comment
2 New beta
New features are better multiple independent charts and prototype compatibilities.
Comment
3 divDomId use
The problem with the tool tip happens if you set it to sometext with a
inside the text. The javascript->object of CakePHP is likely to be the responsible for addind a \ before the / and result in
passed to the swf and this is not something OFC likes... Using the HTML4
is working though as a workaround !
Thanks, and I'll get an eye on 3.3.1. :)
Comment
4 Re: divDomId use
About your tooltip thing, I'll look more into it, but yea, using just
<br>works for the tooltip as per examples in the OFC2 docs.Comment
5 newbie problems
Today was my first day trying Cake Helpers and OFC. After a couple of hours I've finally managed to display a simple chart. For anyone not familiar with the FlashChart helper, I think this information will turn out very helpful:
1. besides including the Flash helper (which you will not use yourself, but is used in the FlashChart helper), you need to include the swfobject.js in your page. I did this with a simple link('swfobject.js'); ?> in my view
2. now for the really tricky part, which I could not find in the online documentation (good think I peaked in the FlashChart helper source code):
after echoing the result of the chart() method call, YOU NEED TO echo the result of the render() method call like this:
echo $flashChart->chart();
echo $flashChart->render();
Of course you can add all the desired parameters to the chart method call. Also keep in mind that the render method accepts four parameters: $width = null, $height = null, $chartId = 'default', $domId = false.
Comment
6 Re: newbie problems
If you download the package files from the google project, they should include both the FlashHelper and the swfobject.js files that is required, so you shouldn't have to include these yourself.
So to summarize. This article is consistent with version 3.1 (also available on the google code page), but NOT version 3.3 (which has some api changes). I keep the documentation in the file itself updated, so that is really the best place to find out how to use it.
Comment
7 3.3.2
just one notice for starter - there is a bug in your helper at start, public $swf = 'flash/open-flash-chart.swf'; instead of public $swf = 'open-flash-chart.swf';
(in zip file, .swf file is in webroot so if this not removed it just shows white square without graph).
But, besides that, you said that this version works with prototype, but when i start it, flash debug window opens with this text (same as in previous versions):
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at JsonInspector$/has_pie_chart()
at main/build_chart()
at main/parse_json()
at main/find_data()
at main()
When not including prototype.js, everything works.
Am i overseeing something or there actually is some bug or whatever?
Thank you.
UPDATE: I noticed now options for begin method:
* @param array $options valid options are 'prototype'
* @example $flashChart->begin(array('prototype'=>true));
Just a suggestion, maybe to put it at the begining of the helper to emphasize it, so that people don't have to look through the code.
Thank you for your effort in making all this.
Comment
8 New release, new api
Also I have set up an svn at the google code project : http://code.google.com/p/alkemann/source/checkout
Comment
9 Small mod
if (is_numeric($width) || preg_match('/^\d+%$/', $width)) {
and in line 351:
if (is_numeric($height) || preg_match('/^\d+%$/', $height)) {
Thanks!
Question
10 Ruh roh no more!
Works great! Thanks for a great helper!
Comment
11 Very handy
Question
12 Pie Chart
echo $flashChart->begin(array('prototype'=>true));
$flashChart->setToolTip('#percent# of 100%');
$flashChart->setTitle('Cake chart','{color:#f1a334;font-size:25px;padding-bottom:20px;}');
$flashChart->setData(array(13,3));
echo $flashChart->pie(array('start_angle' => 59,'values' => 'true', 'tooltip' => '#val# of #total#<br>#percent# of 100%'));
echo $flashChart->render(400,250);
I was able to get the pie chart displayed, but how can I define my own colors and have a legend for the two parts of the pie
Thanks
Comment
13 IE Issue
Question
14 Problem when trying to load new JSON data
I'm trying to reproduce this example using this helper (http://teethgrinder.co.uk/open-flash-chart-2/tutorial/chart-5.php) Where clicking a link, this would load new JSON data into an existing chart, and generate a new chart. When I do this, I get the javascript error:
"tmp.load() is not a function"
I've been trying to compare the two flash objects that get created in the example, and the way cake makes it. The difference I see is that flash params are used as the data holder using the cake method, whereas the flash object in the example does not .
Has anyone else encountered this problem?
Sorry if this sounds like crazy rambling, let me know if anything needs clarifying.
Question
15 How to show keys
Comment
16 Rotated Labels
public function axis($axis, $options = array(), $labelsOptions = array()) {
..........
if ($axis == 'x' && is_string($this->labelsPath) && !empty($this->labelsPath) ) {
if (sizeof($labelsOptions) > 0) {
$labels = Set::extract($this->data, $this->labelsPath);
$x_axis_label = new x_axis_labels;
foreach ($labelsOptions as $key => $setting) {
$set_method = 'set_' . $key;
$x_axis_label->$set_method($setting);
}
$x_axis_label->set_labels($labels);
$axis_object->set_labels($x_axis_label);
} else {
$labels = Set::extract($this->data, $this->labelsPath);
$axis_object->set_labels_from_array($labels);
}
} elseif (isset($options['labels']) && is_array($options['labels'])) {
// Here it should check vertical parameter using $labelOptions
if (isset($labelsOptions['vertical']) && $labelsOptions['vertical'] == true) {
$x_axis_label = new x_axis_labels;
$x_axis_label->set_vertical();
$x_axis_label->set_labels($options['labels']);
$axis_object->set_labels($x_axis_label);
} else {
$axis_object->set_labels_from_array($options['labels']);
}
} elseif (isset($options['labels'])) {
$axis_object->set_labels($options['labels']);
}
$this->Chart->$axis_set_method($axis_object);
}
Question
17 Can't seem to set x-axis labels
$flashChart->setData($months, '{n}.totals.sum_qty_verified','{n}.month');Here's my data ($months array): http://bin.cakephp.org/view/1970674324
It correctly plots the totals.sum_qty_verified but the x-axis labels are just numbered 0 to whatever no matter what I try. I am wanting to have them labelled with the $months[]['month'] value (the name of the month). Can someone suggest how to fix this? Do I need to re-structure my $months array?
Thanks
Chris
Comment
18 Answering my own question...
$flashChart->axis('x',array('tick_height' => 5,'3d' => -20),array('vertical' => true));Wasted an evening on that! Great helper though, so thank you!
Comment
19 distinct month, then chart doesn't show up
controller:
$this->set('datamonths',$this->Finance->find('all', array('fields' => array('DISTINCT MONTH(Finance.created) AS created','SUM(Finance.cost) AS cost'),'order' =>'created','group'=>'created')));
view:
echo $flashChart->begin();
$flashChart->setData($datamonths, '{n}.cost','{n}.created');
$flashChart->setLegend('x','Month');
$flashChart->setLegend('y','Expenditure', '{color:#AA0aFF;font-size:20px;}');
$flashChart->axis('x',array('tick_height' => 5,'3d' => -20),array('vertical' => true));
$flashChart->axis('y',array('range' => array(0,10000,1000)));
echo $flashChart->chart();
echo $flashChart->render();
Please help!
Question
20 How to solve IE issues ...
I was able to display all the charts nice and pretty looking in Firefox, but IE (6, 7 and 8 ) is a nightmare, it could not diplay the charts.
I don't know if you guys have similar problem ? I am using :
PHP 5
Flash chart Helper : 3.3.7
Question
21 How to show key in chart?
$bar->key('mykey');in this tuterial i can't find that, help me please....T T
Comment
22 I can add it..but..
echo $flashChart->chart('bar_glass',array('colour'=>'#33cc33','key'=>'Computer'),'Set1','dig');
echo $flashChart->chart('bar_glass',array('colour'=>'#D54C78','key'=>'Computer2'),'Set2','dig');
echo $flashChart->chart('bar_glass',array('colour'=>'#3334AD','key'=>'Computer3'),'Set3','dig');
but my page show an error
Warning (2): Missing argument 2 for bar_base::set_key(), called in D:\wamp\www\024_kpi2\app\views\helpers\flash_chart.php on line 466 and defined [APP\vendors\flashchart\ofc_bar_base.php, line 13]
Code | Context
$text = "Computer"
* @param $size as integer, size in pixels
*/
function set_key( $text, $size )
bar_base::set_key() - APP\vendors\flashchart\ofc_bar_base.php, line 13
FlashChartHelper::chart() - APP\views\helpers\flash_chart.php, line 466
include - APP\views\mains\index.ctp, line 22
View::_render() - CORE\cake\libs\view\view.php, line 662
View::render() - CORE\cake\libs\view\view.php, line 376
Controller::render() - CORE\cake\libs\controller\controller.php, line 799
Dispatcher::_invoke() - CORE\cake\dispatcher.php, line 230
Dispatcher::dispatch() - CORE\cake\dispatcher.php, line 194
[main] - APP\webroot\index.php, line 88
Notice (8): Undefined variable: size [APP\vendors\flashchart\ofc_bar_base.php, line 17]
How to solve it?............
At last I can do it by
'key'=>array('Computer',12)echo $flashChart->chart('bar_glass',array('colour'=>'#33cc33','key'=>array('Computer',12)),'Set1','dig');
echo $flashChart->chart('bar_glass',array('colour'=>'#D54C78','key'=>array('Computer2',12)),'Set2','dig');
echo $flashChart->chart('bar_glass',array('colour'=>'#3334AD','key'=>array('Computer3',12)),'Set3','dig');
Question
23 How to set a label in the chart data
echo $flashChart->begin(array('prototype'=>true));$flashChart->setTitle('title', '{color:#f1a334;font-size:25px;padding-bottom:20px;}');
echo $flashChart->setData(array(1,3,6,9), '{n}', false, 'stuff');
echo $flashChart->chart('pie', array(), 'stuff', 'chart1');
echo $flashChart->render(400, 400, 'chart1', 'chartDomId1');
but instead of showing numbers, i want to display the label of the data. i tried to create the label following the example below. but it doesn't work.
http://code.google.com/p/alkemann/wiki/ExampleCustomize
anyone can help? thanks very much for your help.
Kit
Comment
24 Easy to show label in your chart...
You can add
echo $flashChart->chart('bar_glass',array('colour'=>'#33cc33','key'=>array('Computer',12)),'Set1','dig');in'key'=array('your label',12)that is label you can set...Comment
25 how about labeling a particular value?
but what about if i want to label the particular value? for example, in the pie chart. there are 4 sectors
rabbit = 1
mouse = 3
cat = 6
dog = 9
i want to show the name of each animal together with its corresponding value in the pie chart.
is that possible? thanks.
Comment
26 Full concept in a chart...
but what about if i want to label the particular value? for example, in the pie chart. there are 4 sectors
rabbit = 1
mouse = 3
cat = 6
dog = 9
i want to show the name of each animal together with its corresponding value in the pie chart.
is that possible? thanks.
1.1 data set = 1 bar<?php
//print_r($data1);
echo $flashChart->begin();
$flashChart->setTitle('Title Name',array('{font-size:20px}'));
$flashChart->setData($data1,'{n}.Point.point','{n}.Indicator.code','Set1','dig');
$flashChart->setData($data2,'{n}.Point.point','{n}.Indicator.code','Set2','dig');
$flashChart->setData($data3,'{n}.Point.point','{n}.Indicator.code','Set3','dig');
$flashChart->setData($data4,'{n}.Point.point','{n}.Indicator.code','Set4','dig');
$flashChart->setLegend('x','X Legend ');
$flashChart->setLegend('y','Y Legend' );
$flashChart->axis('y',array('range' => array(0, 3, 1),'labels' => array('','1','2','3')));
$flashChart->axis('x',array('range' => array(0, 14, 1),'labels' => array('','1','2','3','4','5','6','7','8','9','10','11','12','13','14')));
$flashChart->setBgColour('FFFFE1');
//$flashChart->ready = 'alert("ready");' ;
//$flashChart->loading = 'alert("Processing");' ;
$flashChart->setToolTip(false, array(
'proximity' => true,
'colour' => '338833',
'stroke' => 3,
'hover' => true));
echo $flashChart->chart('bar_glass',array('colour'=>'#33cc33','key'=>array('Rabit ','13')),'Set1','dig');
echo $flashChart->chart('bar_glass',array('colour'=>'#D54C78','key'=>array('Mouse ','13')),'Set2','dig');
echo $flashChart->chart('bar_glass',array('colour'=>'#3334AD','key'=>array('Cat ','13')),'Set3','dig');
echo $flashChart->chart('bar_glass',array('colour'=>'#333333','key'=>array('Doc ','13')),'Set4','dig');
echo $flashChart->render('100%',500,'dig');
?>
2.a chart has id(dig) it's mean morethan 1 chart per page.
'key'=>array('Doc ','13'13=font sizeComment
27 how to define the data field?
i followed your sample. but i would like to ask what does the $data look like? i define the$data1, ... $data4 as follow
$data1 = array('key1' => array('Point' => array('point' => 1), 'Indicator' => array('code' => 'rabbit')));$data2 = array('key2' => array('Point' => array('point' => 2), 'Indicator' => array('code' => 'mouse')));
$data3 = array('key3' => array('Point' => array('point' => 3), 'Indicator' => array('code' => 'cat')));
$data4 = array('key4' => array('Point' => array('point' => 4), 'Indicator' => array('code' => 'dog')));
but only a graph without data is shown.
thanks for your kind help. =)
Comment
28 I got the answer
<?php$data = array(0 => array('Animal' => array('id' => 1, 'name' => 'Rabbit', 'quantity' => 123)),
1 => array('Animal' => array('id' => 2, 'name' => 'mouse', 'quantity' => 78)),
2 => array('Animal' => array('id' => 3, 'name' => 'dog', 'quantity' => 98)),
3 => array('Animal' => array('id' => 4, 'name' => 'cat', 'quantity' => 65)),
);
echo $flashChart->begin(array('prototype'=>true));
$flashChart->setTitle('Chart Title', '{color:#f1a334;font-size:25px;padding-bottom:20px;}');
echo $flashChart->setData($data, '{n}.Animal.quantity', '{n}.Animal.name', 'stuff');
echo $flashChart->chart('pie', array(), 'stuff', 'chart1');
echo $flashChart->render(400, 400, 'chart1', 'chartDomId1');
?>
<div id="chartDomId1"></div>
Comment
29 Pie Colors
u need replace :
$flashChart->pie(array('start_angle' => 59,'values' => 'true', 'tooltip' => '#val# of #total#
#percent# of 100%'));
to
$flashChart->pie(array(
'start_angle' => 59,
'values' => 'true',
'tooltip' => '#val# of #total#
#percent# of 100%',
'colours'=> array('#AA0aFF','#f1a334','#FFF333','#AAA333','#FAF333','#AAFA33')
));
$flashChart->pie(array('colours'=> array('#AA0aFF','#f1a334','#FFF333','#AAA333','#FAF333') ));
Question
30 Multiple Chart Labels
Thanks for this nice helper.
I tried creating two charts on the same page by following the example in the flash chart helper but seems the second chart is using the x-axis labels of the first chart. How do I set different x-axis labels?
i'm using FlashChartHelper version 3.3.91, Cake 1.2.3
echo $flashChart->begin(array('prototype' => true));
$flashChart->setTitle('Status of Targets','{font-weight:bold;font-size:12px;padding-bottom:0px;}');
$flashChart->setData($misTaskStatuses,'{n}.MisTaskStatus.tasks', '{n}.MisTaskStatus.name');
echo $flashChart->chart('pie', array('colours' => array('#B30003', '#ECC729', '#59DC0B'), 'animate' => true, 'tooltip' => '#val# of #total# tasks<br>#percent# of 100%'));
echo $flashChart->render(500, 300);
$labels = array( 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun');
$flashChart->setTitle('History','{color:#880a88;font-size:18px;padding-bottom:20px;}');
$flashChart->setData(array(1,2,4,8, 15),'{n}',false,'Completed', 'history');
$flashChart->setData(array(3,4,6,9),'{n}',false,'Pending', 'history');
$flashChart->setData(array(2,3,7,4),'{n}',false,'Not Started', 'history');
$flashChart->axis('x',array('labels'=> $labels, 'tick_height' => 10),array('colour'=>'#aaFF33', 'vertical' => false));
$flashChart->axis('y',array('range' => array(0, 20, 5)));
$flashChart->setLegend('x', 'Months', '{font-size:14px;color:#CCCCCC;}');
$flashChart->setLegend('y', 'Tasks', '{font-size:14px;color:#CCCCCC;}');
echo $flashChart->chart('bar_3d',array('colour'=>'#8CE624'),'Completed', 'history');
echo $flashChart->chart('bar_3d',array('colour'=>'#FFB505'),'Pending', 'history');
echo $flashChart->chart('bar_3d',array('colour'=>'#B30003'),'Not Started', 'history');
echo $flashChart->render(500, 300, 'history');
Question
31 Prototype and script.aculo.us libraries for Ajax VS Flash Chart Helper
But, I have a problem with that, if I include Prototype and script.aculo.us libraries for Ajax in my layout (called default.ctp), and If I try to display a Flash Chart it dont show. But if the Prototype and script.aculo.us libraries are not included in that layout the Flash Chart Works (shows), what could be the problem ?
Someone can Help me with that !!!
!! De antemano Gracias !!!
Comment
32 Prototype & Flashchart
Hi,
If you're already using prototype in your application, make sure you tell the helper this through the begin call:
echo $flashChart->begin(array('prototype'=>true));
[FROM DOCUMENTATION].
Comment
33 Thanks
Thanks , Now it Works
Comment
34 Help! Just get a default plot...
Thanks,
Joey
Question
35 Stacked Bar
Thanks for the great helper! I am having a problem with the stacked bar chart, all of the other chart types work no problem - 3d, glass, etc, however when I change the chart to 'bar_stack' I get nothing, no error just a blank square. I have a very simple data set per your example here: http://code.google.com/p/alkemann/wiki/ExampleStacked and am using the link to prototype and swfobject as outlined above. I noticed you mentioned a bug with stacked bar on your google code page, did you release a fix? I am using helper v3.3.91
Matt
Question
36 Displaying time values in Yaxis
e.g.
$flashChart->setData(array(27.5,28.25,27.75,28.0,26.5));
$flashChart->setLegend('y','Time' );
$flashChart->axis('y',array('range' => array(20,30,1)));
echo $flashChart->chart('line');
echo $flashChart->render();
I want the tip to display 27:30,28:15,27:45,28:0,26:30 (or similar)
Any ideas I'm sure someone must of done something similar
Cheers, Colin
Comment
37 Time in Y axis
$chartTime=array(27.5,28.25,27.75,28.0,26.5);
$actualTime=array('27:30','28:15','27:45','28.00','26.:0');
for( $i=0; $i<5; $i++ ){
$tmp = new dot($chartTime[$i]);
$tmp->tooltip( "#x#
Time $actualTime[$i]" );
$chart[]=$tmp;
}
$flashChart->setData($chart);
Question
38 Number format in tooltips
Any ideas how to force 2 decimal places in the tooltips?
Bug
39 some bugs and how i slove
IE6 cache bug
first time,the chart looks ok,but if you refresh the page in IE6,the chart will got error。and i hack the render function to slove this bug:public function render($width = null, $height = null, $chartId = 'default', $domId = false) {
if (! is_null ( $width )) {
$this->settings ['width'] = $width;
}
if (! is_null ( $height )) {
$this->settings ['height'] = $height;
}
$this->Chart = new open_flash_chart ( );
//BUG! hack for IE cache bug! add a timestamp to the swf address
$this->swf .= '?t=' . mktime ();
return $this->Flash->renderSwf ( $this->swf, $this->settings ['width'], $this->settings ['height'], $domId, array ('flashvars' => array ('get-data' => 'get_data_' . $chartId ) ) );
}
line style can't set default dot style
because of the open flash chart's chaos APIs,this helper missing the default dot style method,need to add this method by hand:foreach ( $options as $key => $setting ) {
switch ($key) {
case 'line_style' :
$line_style = new line_style ( $setting [0], $setting [1] );
$element->line_style ( $line_style );
break;
//BUG! line's befault dot style method!!
case 'default_dot_style' :
$default_dot = new dot ( );
foreach ( $setting as $k => $v ) {
$default_dot->$k ( $v );
}
$element->set_default_dot_style ( $default_dot );
break;
default :
$set_method = 'set_' . $key;
if (is_array ( $setting )) {
$element->$set_method ( $setting [0], $setting [1] );
} else {
$element->$set_method ( $setting );
}
break;
}
}
visible_steps and rotate unavailable
foreach ( $labelsOptions as $key => $setting ) {
$set_method = 'set_' . $key;
//BUG! without this,will skip the visible_steps and rotate config,foreach ( $labelsOptions as $key => $setting ) {
$set_method = 'set_' . $key;
//BUG! without this,will skip the visible_steps config。default method all start with 'set',but this two DIDN'T!
if (in_array ( $key, array ('visible_steps', 'rotate' ) )) {
$set_method = $key;
}
$x_axis_label->$set_method ( $setting );
}
if (in_array ( $key, array ('visible_steps', 'rotate' ) )) {
$set_method = $key;
}
$x_axis_label->$set_method ( $setting );
}
Hope it help.forgive for my poor english.
the detail is in my blog:http://www.fangyuqiang.com/archives/531,it's chinese.
Comment
40 Multiple chart
The multiple chart part is not well documented as pointed Sola Ajayi, so I give the answer for those of you who don't want to waste there time :D
If you want to display multiple chart you must follow this :
View Template:
<?php
echo $flashChart->begin()); // only one call
// First
$flashChart->setTitle('Sample 01');
$flashChart->setData(...); // and others things you want to customize
echo $flashChart->chart('bar', array(), 'default', 'sample1');
echo $flashChart->render(null, null, 'sample1');
// Second
$flashChart->setTitle('Sample 02');
$flashChart->setData(...); // and others things you want to customize
echo $flashChart->chart('bar', array(), 'default', 'sample2');
echo $flashChart->render(null, null, 'sample2');
?>
Don't know if it does the same to you but, in my case, i had to specify a name for each chart(). If i don't, the same datas, titles, ... were repeated in each chart.
Comment
41 multiple charts....and increments?
$flashChart->begin();
.
.
.
$flashChart->setTitle('Title');
$flashChart->setData($data, '{n}', false, 'stuff','chart1');
echo $flashChart->pie(array(), 'stuff', 'chart1');
echo $flashChart->render(500,500, 'chart1');
$flashChart->setTitle('Title 2');
$flashChart->setData($data2, '{n}', false, 'stuff2', 'chart2');
echo $flashChart->pie(array(), 'stuff2', 'chart2');
echo $flashChart->render(500,500, 'chart2');
Anything else and it wouldn't work (I tried more stuff like axis labels etc. nothing worked unless it was exactly like this).
I am also having trouble with increments on the bar chart. I set a variable to be 1/6th that of the maximum value in the array data, so that it would always be a reasonable range (start,max,increments). But when I send it the data it doesnt set those increments. It is only after refreshing the page (F5) that it realigns itself according to my preset increments...?
Edit: The increments problem didnt occur on another machine I was using, which leads me to believe it may be a flash problem, or a config problem with my machine.
Comment
42 FCH for 1.1
in /app/views/helpers/flash_chart.php change the lines
toApp::import('Vendor', 'flashchart/open-flash-chart');
class FlashChartHelper extends AppHelper {
...
vendor('flashchart/open-flash-chart');
class FlashChartHelper extends Helper {
...
and in /app/views/helpers/flash.php change the line
toclass FlashHelper extends AppHelper {
...
class FlashHelper extends Helper {
...
and in the init function of the same file, replace all this
with this$view =& ClassRegistry::getObject('view');
if (is_object($view)) {
$view->addScript($this->Javascript->link('swfobject'));
return true;
} else {
return $this->Javascript->link('swfobject');
}
return $this->Javascript->link('swfobject');
And that's it! HTH
Question
43 IE 8 Problem
I get the following error:
Comment
44 Awesome, thanks!