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

Front Page

The datatable above was generated with the following WordPress shortcode using the YUI Widgets Plugin:
[ magseven 
	title='Customer Survey' 
	type='abc'
	filename = 'cdpk.csv'
	showlegend = 1 
]

Specialized Charts for the YUI3 Widgets Plugin

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

Code for the YUI Widget Plugin can be obtained from github. Note that it is not ready to run out of the box. If you know what you are doing and wish to play around please feel free to download it.

  1. Pareto Chart
  2. ABC Analysis
  3. Histogram
  4. MarkerSeries Chart or Scatter-Plot
  5. MarkerSeries Chart with an Added Trendline
  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?

The above was generated with the a WordPress shortcode using the YUI Widgets Plugin. The gist shortcode source is available here.

YUI Pie Chart

Jul 23, 2012 by Serge Karalli

Pie Chart Example

The above was generated with the following WordPress shortcode using the YUI Widgets Plugin:

[ yuichart
	title ='Weekday Taxes' 
	type ='pie' 
	filename = 'test2.csv'
	showlegend = 1
]

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.

The above was generated with the a WordPress shortcode using the YUI Widgets Plugin. The gist shortcode source is available here.

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.

The datatable above was generated with the following WordPress shortcode using the YUI Widgets Plugin:
[ yuidatatable
    filename = 'test3.csv'
    caption = 'Multiple-Series Data Table'
    sortable = '0,1,1,1,1,1'
    formatter = 'NULL,dollar,euro,dollar,number,euro'
]

YUI Charts Plugin -- import CSV Datafile

Jun 7, 2012 by Serge Karalli

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 4.x.x...

YUI 3.5.1 now comes with a Legend option. More marker shapes are slated for the YUI 3.6.0 a future 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