EzDevInfo.com

open_flash_chart

The ruby on rails plugin for teethgrinder's Open Flash Chart (version 2) PullMonkey Projects: Open Flash Chart II Plugin for Ruby on Rails - Graphs (OFC 2)

A loop in a loop to fill an array?

I am building a time registration program. Users can work on a project, and I want to display in a chart how many hours each user worked on a project, let's say, each month. The chart plugin works like this:

first_serie = OpenFlashChartLazy::Serie.new(
[["2008-1",100],["2008-2",120],["2008-3",130]],
{:title=>"name_of_user1",:start_date=>Time.mktime(2008,1,1),:items=>8})

This adds a new line in the graph.

My question is how can I loop through all my users and for each fill a new series with data from the database?


Source: (StackOverflow)

how to use Open flash chart (or any library) in flex 3 project?

I want to use Open Flash Chart in Flex3/AS3 project?

I mean, How Can I use Open-flash-chart in Flex application client side.. ??? (I use FlashDevelop)

Can i do that by just adding .swf file?? If yes? then where to add? I am not using FlexBuilder, I am using FlashDevelop OR Command line for compiling..

Or I have to add .swc file.. ??? If yes, then how to generate one for open flash chart..???

Cheers...


Source: (StackOverflow)

Advertisements

How to Display the Total Order Amount per Day in a Chart

I cant seem to get this working, i need to display the Total Order Amount per day on the Chart.

I got the Open Flash chart to work by the following code:


<?php

// Settings for Database Connection
include_once($root_folder_path . "includes/common.php");
include_once("./admin_common.php");
include_once("./ofc_chart_library/open-flash-chart.php");

$sql = "SELECT * from orders ORDER BY order_placed_date";
   if (!$sql) die('Invalid query: ' . mysql_error());

$result = mysql_query($sql);

$data = array();

while($row = mysql_fetch_array($result))
{
  $data[] = intval($row['order_total']);
}

/*
 *  Create a title object and set the text to present month.
 */
$title = new title( 'Monthly Sales Statistics for ' . date("F Y") . ' (US Dollar)' );
$title->set_style( "{font-size: 18px; font-family: Calibri; color: #808000; text-align: center;}" );

//Make our Bar Chart
$bar = new bar_filled('#f99bd6', '#ee0099');
$bar->set_values($data);

//Create a new Chart object
$chart = new open_flash_chart();

// add the title to the chart:
$chart->set_title( $title );
$chart->set_bg_colour("#FFFFFF");

// Display the bar object on the chart
$chart->add_element($bar);

/*
*  Create a Y Axis object
*/
$y_axis = new y_axis();
$y_axis->set_range(0, 12000, 1000);

// Add the y-axis object to the chart
$chart->add_y_axis($y_axis);

echo $chart->toPrettyString();
?>


Now the above code displayed fine, here is the snapshot:

What i want is to display the Date on the X-Axis, taking the date values from my MySQL Database.

Here are how the dates are stored in my database, which is a DateTime Type:

2008-12-30 00:06:24
2009-02-03 01:57:17
2009-02-03 01:58:27
2009-05-03 01:58:48
2009-06-03 02:00:31
2009-07-03 02:01:47
2009-07-03 02:02:31
2009-07-04 14:21:18
2009-07-04 14:21:36
2009-07-04 14:22:18
2009-07-04 14:23:29
2009-07-04 14:24:24

I tried the following code to display the Date in the X-Axis:


<?php

include_once 'php-ofc-library/open-flash-chart.php';

//Connect to MySQL Database
$con = mysql_connect("localhost", "root", "password");
    if (!$con) die('Could not connect : ' . mysql_error());
$db_selected = mysql_select_db("cart",$con);
    if (!db_selected) die ("Could not find the database: " . mysql_error());

$sql = "SELECT * from orders ORDER BY order_placed_date";
    if (!$sql) die('Invalid query: ' . mysql_error());

$result = mysql_query($sql);

$amountData = array();


while($row = mysql_fetch_array($result))
{
  $amountData[] = intval($row['order_total']); 
}

$chart = new open_flash_chart();
$chart->set_title(new title('Open Flash Chart Downloads'));

//Make Bar Chart
$bar = new bar_filled('#df95c3', '#f34db7');
$bar->set_values($amountData);

//Create a new Chart object
$chart = new open_flash_chart();

/*
 *  Create a title object and set the text to present month.
 */
$title = new title( 'Monthly Sales Statistics for ' . date("F Y") . ' (US Dollar)' );
$title->set_style( "{font-size: 18px; font-family: Calibri; color: #808000; text-align: center;}" );

// add the title to the chart:
$chart->set_title( $title );
$chart->set_bg_colour("#FFFFFF");


// Add the bar object to the chart
$chart->add_element($bar);


//
// create an X Axis object
//
$x_axis = new x_axis();
// grid line and tick every 10
$x_axis->set_range(
    mktime(0, 0, 0, 1, 1, date('Y')),    // <-- min == 1st Jan, this year
    mktime(0, 0, 0, 1, 31, date('Y'))    // <-- max == 31st Jan, this year
    );
// show ticks and grid lines for every day:
$x_axis->set_steps(86400);

$labels = new x_axis_labels();
// tell the labels to render the number as a date:
$labels->text('#date:d#');
// generate labels for every day
$labels->set_steps(86400);
// only display every other label (every other day)
$labels->visible_steps(1);


// finally attach the label definition to the x axis
$x_axis->set_labels($labels);


$y_axis = new y_axis();
$y_axis->set_range(0, 3000, 200);

// Display the Axis on the Chart
$chart->set_x_axis($x_axis);
$chart->add_y_axis($y_axis);

echo $chart->toPrettyString();


?>


Here is what i got:

the Amount is being shown, but there are all in one line at the 0 x-axis.

How can I solve this problem, so get the Order Dates from the Database and then display them on the Chart according to the date the order was placed.

============================================================

Below is the JSON data for both Order Totals and the Date they were placed.


<?php

include_once 'php-ofc-library/open-flash-chart.php';

//Connect to MySQL Database
$con = mysql_connect("localhost", "root", "password");
    if (!$con) die('Could not connect : ' . mysql_error());
$db_selected = mysql_select_db("cart",$con);
    if (!db_selected) die ("Could not find the database: " . mysql_error());

$sql = "SELECT * from orders ORDER BY order_placed_date";
    if (!$sql) die('Invalid query: ' . mysql_error());

$result = mysql_query($sql);

$dateData = array();
$TotalAmountData = array();

while($row = mysql_fetch_array($result))
{
  $TotalAmountData [] = intval($row['order_total']);
  $dateData[] = $row['order_placed_date'];

}

print '<pre>';
print_r( $TotalAmountData );
print_r( $dateData );
print '</pre>';[/code]

?>


This shows the following JSON data:

Array  // This is the Total Order Amount Per Day
(
    [0] => 2499
    [1] => 199
    [2] => 449
    [3] => 299
    [4] => 359
    [5] => 279
    [6] => 1359
    [7] => 5099
    [8] => 2621
    [9] => 2169
    [10] => 2249
    [11] => 5509
)
Array // This is the DateTime on which the orders where placed
(
    [0] => 2008-12-30 00:06:24
    [1] => 2009-02-03 01:57:17
    [2] => 2009-02-03 01:58:27
    [3] => 2009-05-03 01:58:48
    [4] => 2009-06-03 02:00:31
    [5] => 2009-07-03 02:01:47
    [6] => 2009-07-03 02:02:31
    [7] => 2009-07-04 14:21:18
    [8] => 2009-07-04 14:21:36
    [9] => 2009-07-04 14:22:18
    [10] => 2009-07-04 14:23:29
    [11] => 2009-07-04 14:24:24
)

I tried to select the Date by removing the Time from the Date:

SELECT DATE_FORMAT(order_placed_date, '%m-%d-%Y'), order_total FROM orders

But the above code showed Empty values for JSON Data

Update: Can anyone help ?


Source: (StackOverflow)

How to implement such tool-tip in open-flash-chart 2.x

i think what i need is the tooltip like the tooltip in 1.x

the magicword #tip# 's function.


Source: (StackOverflow)

How to define apostrophe as thousand separator character in OFC2?

I would like to separate numbers with more then 3 digits with another character then a comma or a dot in Open Flash Chart 2.

In my region/country we format a big amount like this: 1'234'567.95

I only found the way to choose between a comma or a dot as a thousand separator here:
http://teethgrinder.co.uk/open-flash-chart-2/doxygen/html/classopen__flash__chart.html

How can I define the apostrophe character ' as number format separator like in #'###.00


Source: (StackOverflow)

Use High-charts, Open Flash Chart 2, Google Charts or what else !

One web application of ours requires a feature of displaying charts in it. Basically we have to show different types of charts for different purposes such as pie charts to give information about some purpose,Bar charts for some other purpose whereas Complex charts for complex data.Note that this charts will be created dynamically depending on the data in the MySQL database so we cannot use simple images.

I have been told to read the integrate this feature in our application.I Google and found High-charts,Open Flash Chart 2,Google Charts. What should I use as I don't have experience of integrating charts.


Source: (StackOverflow)

Open Flash Chart on Zend MVC Error

I recently downloaded the Open Flash Chart source code and I have intergrated it into my Zend MVC.Since I use the autoloader I have renamed my files and commented the "require_once" source lines.

However when I try to load my chart

<script type="text/javascript">
    swfobject.embedSWF(
        "<?php echo $this->baseUrl() ?>/swf/open-flash-chart.swf", 
        "my_chart", "550", "200",
        "9.0.0", 
        "<?php echo $this->baseUrl() ?>/swf/expressInstall.swf",
        {"data-file":"<?php echo $this->baseUrl()?>/reportexpense/piechart/"}
    );
    </script>

it loads the "/data-files/y-axis-auto-steps.txt" instead and I cant figure out why.

My controller returns the JSON string which I expect to be rendered. What am I missing?


Source: (StackOverflow)

JSON Parsing Error

I got problem. I have this JSON automatically generated by Open Flash Chart php library. The problem is, OFC report JSON Parse Error [Syntax Error] while test result using http://www.jsonlint.com/ report that my JSON is fine. But, w3c parser report error too:(

Any help?

Here's the JSON:

{
    "title": "Followers Trend",
    "elements": [
        {
            "type": "area_hollow",
            "fill-alpha": 0.35,
            "values": [

            ],
            "colour": "#5B56B6",
            "text": "Followers",
            "font-size": 12 
        } 
    ],
    "x_axis": {
        "colour": "#A2ACBA",
        "grid-colour": "#D7E4A3",
        "offset": false,
        "steps": 4,
        "labels": {
            "steps": 2,
            "rotate": "vertical",
            "colour": "#A2ACBA",
            "labels": [

            ] 
        } 
    },
    "x_legend": {
        "text": "Week Trend (2009-08-17 - 2009-08-24)",
        "style": "{font-size: 20px; color: #778877}" 
    },
    "y_axis": {
        "min": 0,
        "max": 150,
        "steps": 30 
    }
}

Source: (StackOverflow)

CSS Menu does not appear over flash

I have a drop-down/multi-level CSS menu on a page. The menu however doesn't appear over a flash chart I have. The apparent fix seems to be to put wmode:transparent (or opaque), but that doesn't work for me. I have also tried setting the z-level in the CSS to very high values (2000) but that doesn't work either.

In addition, I'm using open-flash-chart-v2 to generate the chart. (though I don't think it matters, but it limits my ability to pass variables as I'm not using the embed or object tag directly).

<script type="text/javascript">
swfobject.embedSWF("/ofc-library/open-flash-chart.swf", "chart", "100%", "100%", "9.0.0", "expressInstall.swf", {"wmode" : "transparent"});
</script>

Page showing problem (This doesn't currently show the z-index attempt to fix.)


Source: (StackOverflow)

How to prevent Javascript Menu from getting hidden under Flash Video (SWFObject )

How to prevent Javascript Menu from getting hidden under Flash Video (SWFObject ).

I am using Open Flash Chart and the chart is displaying fine in my php shoppping cart, but my javascript menu is getting hidden behind the Flash Chart.

How to correct this problem?

Here is my script code:


<script type="text/javascript">

swfobject.embedSWF(
  "open-flash-chart.swf", "Dashboard_Chart",
  "800", "400", "9.0.0", "expressInstall.swf",
  {"data-file":"ofc-chart.php"} );

</script>


UPDATE (Solved):

I found the solution.

Here is my new code which works and the menu shows up fine.


<script type="text/javascript">
    var flashvars = {};
    var params = {};
    params.wmode = "opaque";
    var attributes = {};
    swfobject.embedSWF("../swf/open-flash-chart.swf", "Dashboard_Chart", "760", "300", "9.0.0", "expressInstall.swf", {"data-file":"ofc-chart.php"}, flashvars, params, attributes );

</script>



Source: (StackOverflow)

multi graphs datas in zend framework

I'm trying to place multiple graphs in a page to form a dashboard.

I found the way to do that with placing the graphs source code directly in the controller and then display the graphs in the view, but I know it s not 'Clean' to do that especially with mvc.

Do you have an idea how to place my graph codes separately in a model class (as different functions I guess) and get the graphs data results from that model to the controller and then place the graphs in the view?

This is what I have done for 2 graphs (have many more that why I have to find a way to separate the source codes so wont have to change every parameter to be unique in the code:

contoller

  class stjpgController extends Oft_Controller_Action {

  public function init(){
  require_once 'Ofc/ofc_line_base.php';
  require_once 'Ofc/open-flash-chart.php';
  require_once 'Ofc/ofc_line_dot.php';
  require_once 'Ofc/ofc_line_hollow.php';

  }

public function graphAction(){
    $view = $this->view;
    $dateInBetween = array();
    $SmsSum = array();
    $smsSumGraph = array();
    $y_axis_values = array();
    $x_axis_values = array();


    $queryparse = oci_parse($conn, $query);
    oci_execute($queryparse);


    while ($row_date = oci_fetch_array($queryparse,
            OCI_ASSOC+OCI_RETURN_NULLS))
    {
         $y_axis_values[] = intval($row_date['SMSSUM']);
         $x_axis_values[] = $row_date['DATETO'];

    }

    $chart = new open_flash_chart();
    $y_axis = new y_axis();
    $x_axis = new x_axis();

    $default_dot = new line_dot();
    $tooltip = new tooltip();

    $x_labels = new x_axis_labels();
    $x_labels->set_labels($x_axis_values);
         $taille=sizeof($x_labels);
          $step=2;
          if ($taille>100) $step=4;
          if ($taille>200) $step=8;
          if ($taille>300) $step=12;
          if ($taille>400) $step=24;
    $x_labels->set_steps( $step );
    $x_labels->rotate('45');
    $x_axis->set_labels($x_labels);
    $x_axis->set_offset(false);
    $y_axis->set_range( 0, max($y_axis_values)+10, round( max($y_axis_values) / 4 ) );

    $chart->set_x_axis( $x_axis );
    $chart->add_y_axis( $y_axis );

    //LINE
    $line = new line();
    $line->set_values( $y_axis_values );       
    $line->set_halo_size( 0 );
    $line->set_width( 2 );
    $chart->add_element($line);

   $data = $chart->toPrettyString();

   $swfObject  = "swfobject.embedSWF(";
   $swfObject .= "'{$view->baseUrlMedia('ofc/open-flash-chart.swf')}', 'ofcchart',";
   $swfObject .= "'350', '300', '9.0.0', 'expressInstall.swf',";
   $swfObject .= "{'get-data':'get_data_ofc_chart'}, {'wmode': 'transparent'} );";

   $view->jquery()->addOnload("var data = {$data}");
   $view->jquery()->addOnload($swfObject);

   $view->dataChart = $data;

   //------------------------GRAPH 2----------------------------------- 
   $y_axis_values1 = array();
   $x_axis_values1 = array();
   $y_axis_values2 = array();
   $x_axis_values2 = array();

   $SuccRecMsgParse = oci_parse($conn,  $query1);

   oci_execute($SuccRecMsgParse);

   while ($row_date1 = oci_fetch_array($SuccRecMsgParse,
           OCI_ASSOC+OCI_RETURN_NULLS))
   {
       $y_axis_values1[] = intval($row_date1['SMSSUM']);
       $x_axis_values1[] = $row_date1['DATETO'];
   }

   $MOtotalIncParse = oci_parse($conn, $query2);

   oci_execute($MOtotalIncParse);

   while ($row_date2 = oci_fetch_array($MOtotalIncParse,
           OCI_ASSOC+OCI_RETURN_NULLS))
   {
       $y_axis_values2[] = intval($row_date2['SMSSUM']);
       $x_axis_values2[] = $row_date2['DATETO'];
   }




   $y_axis1 = new y_axis();
   $x_axis1 = new x_axis();

   $default_dot = new line_dot();
   $tooltip = new tooltip();

   $x_labels1 = new x_axis_labels();
   $x_labels1->set_labels($x_axis_values1);
   $taille=sizeof($x_labels1);
   $step=2;
   if ($taille>100) $step=4;
   if ($taille>200) $step=8;
   if ($taille>300) $step=12;
   if ($taille>400) $step=24;
   $x_labels1->set_steps( $step );
   $x_labels1->rotate('45');
   $x_axis1->set_labels($x_labels1);
   $x_axis1->set_offset(false);
   $y_axis1->set_range( 0, max($y_axis_values1)+10, round( max($y_axis_values1) / 4 ) );

   $default_dot = new line_dot();
   $default_dot->set_colour('#DFC329');

   $line_dot = new line();
   $line_dot->set_default_dot_style($default_dot);
   $line_dot->set_width( 4 );
   $line_dot->set_colour( '#DFC329' );
   $line_dot->set_values( $y_axis_values1 );
   $line_dot->set_key( "SuccRecMsg", 10 );
   $default_hollow_dot = new line_hollow();
   $default_hollow_dot->set_colour('#6363AC');

   $line_hollow = new line();
   $line_hollow->set_default_dot_style($default_hollow_dot);
   $line_hollow->set_width( 4 );
   $line_hollow->set_colour( '#6363AC' );
   $line_hollow->set_values( $y_axis_values2 );
   $line_hollow->set_key( "MOtotalInc", 10 );


   $chart1 =new open_flash_chart();
   $chart1->set_x_axis( $x_axis1 );
   $chart1->add_y_axis( $y_axis1 );
   $chart1->add_element($line_dot);
   $chart1->add_element($line_hollow);


   $data1 = $chart1->toPrettyString();

   $swfObject1  = "swfobject.embedSWF(";
   $swfObject1 .= "'{$view->baseUrlMedia('ofc/open-flash-chart.swf')}', 'ofcchart1',";
   $swfObject1 .= "'350', '300', '9.0.0', 'expressInstall.swf',";
   $swfObject1 .= "{'get-data':'get_data_ofc_chart1'}, {'wmode': 'transparent'} );";

   $view->jquery()->addOnload("var data1 = {$data1}");
   $view->jquery()->addOnload($swfObject1);

   $view->dataChart1 = $data1;
   }
}

View:

<script type="text/javascript" src="/js/json/json2.js"></script>
<script type="text/javascript" src="/js/swfobject.js"></script>

<?= $this->headScript()->captureStart(); ?>
function get_data_ofc_chart(){
    return JSON.stringify(<?php echo $this->dataChart; ?>);

}

function get_data_ofc_chart1(){
    return JSON.stringify(<?php echo $this->dataChart1; ?>);

}

function findSWF(movieName) {
   if (navigator.appName.indexOf('Microsoft')!= -1) {
        //return window['ie_' + movieName];
        return document.getElementById('ie_'+movieName);
   } else {
        //return document[movieName];
        return document.getElementById(movieName);
   }
}

<?= $this->headScript()->captureEnd(); ?>

<div id="container">
<p></p>
<div id="ofc_chart"></div>
<div id="ofc_chart1"></div>


Source: (StackOverflow)

pentaho: Openflash Chart appears blank

I specified the following configuration in CDE for an openflash chart: the name, html object, title, chart type, datasource (which uses a jdbc connection) and set 3D to true When I click preview, all other CCC charts appear and the space reserved for the openflash chart is blank

Does the openflash chart component work?

Is there anything else I was supposed to configure that I am missing out on?

Rumbi


Source: (StackOverflow)

How do I get the "Install Missing Plugin" yellow bar to appear in firefox when flash is not installed?

My rails website uses the open_flash_graph plugin to generate flash graphs for my clients. If a customer doesn't have flash installed, it doesn't display any messages, it simply doesn't show any graphs.

I've noticed that if I go to other websites that need flash, I get a yellow bar at the top of my firefox window that offers to "Install Missing Plugin".

I assume something in the HTML lets firefox know that this webpage needs flash. What code do I need to add to my website to make this work?


Source: (StackOverflow)

Open flash chart not working on iphone and ipad

I am working of dashboard application in PHP and i use OPEN FLASH CHART-2 for charting framework. and it also successfully working on every browsers on windows. but when i test it on ios then it failed.I didn't change source any more that can effect it.

Now i can't change my framework.please suggest me some idea or possible way to make it working on IPHONE and IPAD.


Source: (StackOverflow)

Internet explorer z-index not working with open flash chart

How to overlap an element over Open-Flash-charts Element that is positioned relatively in Internet Explorer 10.

Its perfectly work in Chrome and firefox and it respectively work with other elements using Z-index also in ie10 but with open-flash-chart, It fails in IE10.

It always appears behind the relatively positioned Open-flash-charts element.Have you any idea then help me.


Source: (StackOverflow)