example1

  1. <?php
  2. // Sets height and width
  3. $flashChart->begin(450, 250, 'Day', 'Month');
  4. $months = array(
  5. __('Jan', true),
  6. __('Feb', true),
  7. __('Mar', true),
  8. __('Apr', true),
  9. __('May', true),
  10. __('Jun', true),
  11. __('Jul', true),
  12. __('Aug', true),
  13. __('Sep', true),
  14. __('Oct', true),
  15. __('Nov', true),
  16. __('Dec', true)
  17. );
  18.  
  19. $flashChart->labels($months);
  20. // Title
  21. $flashChart->title('Example 1 - Bars: Hits per Month');
  22.  
  23. // Prepare some random data (10 points)
  24. $random_hits = $links = array();
  25. for ($i=0; $i < count($months); $i++) {
  26. $random_hits[] = rand(0,1000000);
  27. $links[] = "javascript:alert('hits: " . $random_hits[$i] . "')";
  28. }
  29. // Register each data set with its information.
  30. $data = array(
  31. 'Hits' => array(
  32. 'color' => '#afe342',
  33. 'font_size' => 11,
  34. 'data' => $random_hits,
  35. 'links' => $links,
  36. 'graph_style' => 'bar',
  37. )
  38. );
  39. $flashChart->setData($data);
  40.  
  41. // Show the graph
  42. echo $flashChart->render();
  43. ?>

example2

  1. <?php
  2. // Sets height and width
  3. $flashChart->begin(400, 250, 'Day', '#Hits');
  4.  
  5. // Title
  6. $flashChart->title('Example 2 - Lines: Hits per Day');
  7.  
  8. // Prepare some random data (10 points)
  9. $random_hits = array();
  10. for ($i=0; $i < 10; $i++) {
  11. $random_hits[] = rand(10000,20000);
  12. }
  13. // Register each data set with its information.
  14. $data = array(
  15. 'Hits' => array(
  16. 'color' => '#00aa42',
  17. 'font_size' => 11,
  18. 'data' => $random_hits,
  19. 'graph_style' => 'lines',
  20. )
  21. );
  22. $flashChart->setData($data);
  23.  
  24. // Set Ranges in the chart
  25. // $flashChart->setRange('y', 0, 100);
  26. // $flashChart->setRange('x', 0, 10);
  27.  
  28. // Show the graph
  29. echo $flashChart->render();
  30. ?>

example3

  1. <?php
  2. // Sets height and width
  3. $flashChart->begin(400, 250);
  4. // Title
  5. $flashChart->title('Example 3 - Scatter: Some Random Points');
  6. // Configure Grid style and legends
  7. $flashChart->configureGrid(
  8. 'x_axis' => array(
  9. 'step' => 1,
  10. 'legend' => 'Day'
  11. ),
  12. 'y_axis' => array(
  13. 'legend' => '#Hits',
  14. )
  15. )
  16. );
  17. // Prepare some random data (10 points)
  18. $random_points = array();
  19. for ($i=0; $i < 10; $i++) {
  20. // Each point is represented as a pair (x,y)
  21. $random_points[] = array('x' => $i, 'y' => rand(0,100));
  22. }
  23. // Register each data set with its information.
  24. $data = array(
  25. 'Random Points' => array(
  26. 'color' => '#00aa42',
  27. 'font_size' => 11,
  28. 'data' => $random_points,
  29. 'graph_style' => 'scatter'
  30. )
  31. );
  32. $flashChart->setData($data);
  33.  
  34. // Set Ranges in the chart
  35. $flashChart->setRange('y', 0, 100);
  36. $flashChart->setRange('x', 0, 10);
  37.  
  38. // Show the graph
  39. echo $flashChart->render();
  40. ?>

example4

  1. <?php
  2. $flashChart->begin(400, 250);
  3. $flashChart->title('Example 4 - Pie Chart: My imaginary Browser Stats');
  4. $browser_data = array(
  5. 'Firefox' => array(
  6. 'value' => 30
  7. ),
  8. 'Opera' => array(
  9. 'value' => 7
  10. ),
  11. 'IE' => array(
  12. 'value' => 38
  13. ),
  14. 'Other' => array(
  15. 'value' => 25
  16. )
  17. );
  18. $flashChart->pie($browser_data);
  19.  
  20. echo $flashChart->render();
  21. ?>

example5

  1. <?php
  2. // Sets height and width
  3. $flashChart->begin(400, 250);
  4. // Title
  5. $flashChart->title('Example 5 - Mixed: Hits per Day vs. # Visits');
  6. // Configure Grid style and legends
  7. $flashChart->configureGrid(
  8. 'x_axis' => array(
  9. 'step' => 1,
  10. 'legend' => 'Day'
  11. ),
  12. 'y_axis' => array(
  13. 'legend' => '#Hits',
  14. )
  15. )
  16. );
  17. // Prepare some random data (10 points)
  18. $visits = array();
  19. $random_hits2 = array();
  20. for ($i=0; $i < 10; $i++) {
  21. $visits[] = rand(10,50);
  22. $random_hits2[] = rand(-30,10);
  23. }
  24.  
  25. // debug($random_hits2);
  26. // Register each data set with its information.
  27. $data = array(
  28. 'Visits' => array(
  29. 'color' => '#324aef',
  30. 'font_size' => 11,
  31. 'data' => $visits,
  32. 'graph_style' => 'bar',
  33. ),
  34. 'Hits' => array(
  35. 'color' => '#afe342',
  36. 'font_size' => 11,
  37. 'data' => $random_hits2,
  38. 'graph_style' => 'line_dot',
  39. )
  40. );
  41. $flashChart->setData($data);
  42.  
  43. // Set Ranges in the chart
  44. // $flashChart->setRange('y', 0, 100);
  45. // $flashChart->setRange('x', 0, 10);
  46.  
  47. // Show the graph
  48. echo $flashChart->render();
  49.  
  50. ?>