//PIE chart, 60% alpha // $this->graph->pie(80,'#505050','{font-size: 12px; color: #404040;'); // // pass in two arrays, one of data, the other data labels // $this->graph->pie_values( $bp_qty, $bp_label ); // // Colours for each slice, in this case some of the colours // will be re-used (3 colurs for 5 slices means the last two // slices will have colours colour[0] and colour[1]): // $this->graph->pie_slice_colours( array('#d9db35','#487daf','#d00000','#4ae331') );
vcool: I follwed your instructions but the HTML doesn’t display the “embed” tag.. Are you missing a step?
My HTML looks like this: &title=Spoon+sales+2008,{font-size: 26px;}& &x_axis_steps=1& &y_ticks=5,10,6& &line=3,#87421F& &values=49,11,20,12,0,42,50,0,30,50,49,49& &x_labels=Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec& &y_min=0& &y_max=60&
Add this helper file (‘open_flash_chart_helper.php’)
<?php
function open_flash_chart_object( $width, $height, $url, $use_swfobject=true, $base='' ) { // // I think we may use swfobject for all browsers, // not JUST for IE... // //$ie = strstr(getenv('HTTP_USER_AGENT'), 'MSIE');
// // escape the & and stuff: // $url = urlencode($url);
// // output buffer // $out = array();
// // check for http or https: // if (isset ($_SERVER['HTTPS'])) { if (strtoupper ($_SERVER['HTTPS']) == 'ON') { $protocol = 'https'; } else { $protocol = 'http'; } } else { $protocol = 'http'; }
// // if there are more than one charts on the // page, give each a different ID // global $open_flash_chart_seqno; $obj_id = 'chart'; $div_name = 'flashcontent';
Just a note, it looks like if you use the method in the first post (not the helper provided by taewoo, I haven’t tried that yet), you MUST have some other HTML element in the page, or something in swfobject.js will fail, causing no graph to show, even though the code is on the page.
Does not work:
<?php //PIE chart, 80% alpha $this->graph->pie(80,'#505050','{font-size: 12px; color: #404040;'); // pass in two arrays, one of data, the other data labels $this->graph->pie_values( $values, $labels ); // Colours for each slice, in this case some of the colours // will be re-used (3 colurs for 5 slices means the last two // slices will have colours colour[0] and colour[1]): $this->graph->pie_slice_colours( array('#d9db35','#487daf','#d00000','#4ae331') );
<h1>Test Graph</h1> <?php //PIE chart, 80% alpha $this->graph->pie(80,'#505050','{font-size: 12px; color: #404040;'); // pass in two arrays, one of data, the other data labels $this->graph->pie_values( $values, $labels ); // Colours for each slice, in this case some of the colours // will be re-used (3 colurs for 5 slices means the last two // slices will have colours colour[0] and colour[1]): $this->graph->pie_slice_colours( array('#d9db35','#487daf','#d00000','#4ae331') );
The only difference between the two is that I added a h1 in the working example. These are views, by the way.
I like to do all the formatting/creation of the charts in the views in order to have more than 1 chart per page, and pass in the data arrays from the controller. I also copied the code in the constructor to a clear() function. It is used exactly like the table library’s clear function and has the same purpose.
/** * Resets all variables to initial state. */ function clear() { $this->data_sets = array();
// which data lines are attached to the // right Y axis? $this->y2_lines = array();
// Number formatting: $this->y_format=''; $this->num_decimals=''; $this->is_fixed_num_decimals_forced=''; $this->is_decimal_separator_comma=''; $this->is_thousand_separator_disabled='';
$this->output_type = '';
// // set some default value incase the user forgets // to set them, so at least they see *something* // even is it is only the axis and some ticks // $this->set_y_min( 0 ); $this->set_y_max( 20 ); $this->set_x_axis_steps( 1 ); $this->y_label_steps( 5 ); }
Have any of you guys checked this in IE7?
For me it works fine in Firefox, but when I look in IE7 I just get:
“C:\Users\John\Documents\flash\svn\data-files\data-47.txt” which is obviously hard coded somewhere
Hi,
I’ve a problem in implementing the Open Flash Chart (the file open-flash-chart-2-hyperion.zip from the official site). Sorry for the too great details in my question, but I don’t know as to explain my difficulties in other way.
I made a copy of the following files:
1) version-2/open-flash-chart.swf in the root of codeigniter
2) version-2/js/swfobject.js in codeigniter/js.
3) version-2/php5-ofc-library/open-flash-chart-object.php in system/application/helpers/ and I renamed this file as open-flash-chart_helper.php
4) version-2/php-ofc-library/open-flash-chart.php in system/application/libraries/ and I renamed this file as graph.php and its class open_flash_chart as graph:
5) because of include_once in the file graph.php, I copied also the other files from version-2/php-ofc-library/ in the same directory where I put the graph.php (system/application/libraries).
My problem is that when I run http://127.0.0.1/codeigniter/index.php/example I get the loading of flash but no drawings. It seems that the method chart doesn’t send to the view the chart settings.
For Open Flash Chart v2, the author separated the php helper files into modules. There’s so many classes. Each type of chart has a set of their own classes. So, there’s no way to implement them along with CI. The current solution is kept on using OFC v1.9.7 (no further development).
I guest, for drawing chart, that is good enough.