Example isn’t another way to teach, it is
the only way to teach.
. —Albert Einstein

Front Page

YUI Special Charts

Aug 19, 2012 by Serge Karalli

I have made it possible to post some special-purpose charts. These are also in their development stages. Below you will finds examples of

  1. Pareto Chart
  2. ABC Analysis
  3. Histogram
  4. MarkerSeries Chart or Scatter-Plot
  5. MarkerSeries Chart with an Added Trenline
  6. The Xbar Control Chart
  7. The R Control Chart

1. Pareto Chart

moreRead the rest of this entry »

YUI TabView Enhancement

Jul 28, 2012 by Serge Karalli

I just updated the YUI TabView addition to the YUI Widgets Plugin collection. It is now possible to embed Charts modules and DataTable widgets inside tab panels.

The following TabView widget contains the following examples:

  1. Content with HTML markup
  2. A Pie Chart
  3. A Line Chart
  4. A DataTable

But I Must Explain

Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?

YUI Pie Chart

Jul 23, 2012 by Serge Karalli

Pie Chart Example

YUI TabView

Jul 22, 2012 by Serge Karalli

Here is a simple YUI TabView addition to the YUI Widgets Plugin collection.

But I Must Explain

Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?

Sed Ut Pespiciatis

But I must explain to you how all this mistaken idea of denouncing pleasure and praising pain was born and I will give you a complete account of the system, and expound the actual teachings of the great explorer of the truth, the master-builder of human happiness. No one rejects, dislikes, or avoids pleasure itself, because it is pleasure, but because those who do not know how to pursue pleasure rationally encounter consequences that are extremely painful. Nor again is there anyone who loves or pursues or desires to obtain pain of itself, because it is pain, but because occasionally circumstances occur in which toil and pain can procure him some great pleasure. To take a trivial example, which of us ever undertakes laborious physical exercise, except to obtain some advantage from it? But who has any right to find fault with a man who chooses to enjoy a pleasure that has no annoying consequences, or one who avoids a pain that produces no resultant pleasure?

On the other Hand

At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Temporibus autem quibusdam et aut officiis debitis aut rerum necessitatibus saepe eveniet ut et voluptates repudiandae sint et molestiae non recusandae. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.

YUI DataTable

Jul 9, 2012 by Serge Karalli

DataTable Example

building on the concepts of my previous post, CSV data, once converted to JSON, is easily displayed in a YUI3 datatable.

YUI Charts Plugin -- import CSV Datafile

Jun 7, 2012 by Serge Karalli

YUI Charts Plugin for WordPress

YUI Charts WP plugin shown with custom legend

As I add functionality to the YUI Charts, my first WordPress plugin, I notice that the YUI version releases moved from YUI 3.4.1 when I took on this project to YUI 3.5.1. I am hoping to complete this project before YUI 3.6.x...

YUI 3.5.1 now comes with a Legend option. More marker shapes are slated for the YUI 3.6.0 release (see enhancement ticket).

A CSV to JSON converter

I just added a CSV to JSON converter so that chart data can be edited in a spreadsheet and uploaded to the server. I started with Jay Williams' PHP function 'Convert a comma separated file into an associated array' on github. The PHP function json_encode() is used to complete the conversion chain to the desired JSON format.

View PHP SCRIPT: 'Convert a CSV string to JSON'
function csv_to_JSON( $input , $delimiter , $request )

Apply the function to CSV data.

 
<?php
	list ($header,$JSONstring) = csv_to_JSON($csvdata, $delimiter);
?>
The function function csv_to_JSON() takes 3 arguments
  1. The value of the first argument is $csvdata , whose value is a CSV-formatted string. An example is given below.
    View INPUT: CSV string $csvdata
  2. The value of the string $delimiter needs to be set to the value separator used in $csvdata . In our example, $delimiter=",".
Values returned by the function csv_to_JSON()

The function csv_to_JSON() returns the array: array ( $JSONdata , $delimiter );

  1. The value of $header is an array of the csv table headers.
  2. Array
    (
    	[0] => Period
    	[1] => Year 1
    	[2] => Year 2
    	[3] => Year 3
    	[4] => Year 4
    	[5] => Year 5
    )
    
  3. The value of $JSONdata is an unformatted JSON string. An example is given below.
    view OUTPUT: unformatted JSON string
    $JSONdata

A JSON formatting function

While an flat JSON string will suit our purposes of generating a YUI chart, a pretty-printed output is easier on the human eye. A JSON indenting function 'Format JSON with PHP' by Software Done Right outputs the JSON string in a more readable format.

View PHP SCRIPT: 'Format JSON withPHP'
function indent( $JSONstring )

Apply the function to a flat JSON string.

<?php
	$prettyJSON = indent($JSONstring);
?>
View OUTPUT: formatted JSON string
$prettyJSON

YUI Charts

Nov 26, 2011 by Serge Karalli

I am developing a WP add-in to display YUI 3 charts. Below is an example of a multiple series chart. The add-in also adds a legend to the chart, a feature that is not available in YUI as of version 3.4.1. Although, legend feature is available in the YUI 3 Gallery entitled "charts-legend", I am creating one that I prefer for the purposes of blogging. Version 3.4.1 allows you to display axis titles.

The plug-in is in its infancy. I will update its progress on this blog. So far it has been tested successfully on FireFox 8, SeaMonkey 2.5, Chrome 16.0, IE 8, and IE 9.

As of 3.6.0, Legends are available for YUI Charts. The examples below display the YUI Charts Legend

Multiple-Series Example

Scatter-Plot Example