6 <title>Engel Curves
</title>
8 <link class=
"include" rel=
"stylesheet" type=
"text/css" href=
"../jquery.jqplot.min.css" />
9 <link rel=
"stylesheet" type=
"text/css" href=
"examples.min.css" />
10 <link type=
"text/css" rel=
"stylesheet" href=
"syntaxhighlighter/styles/shCoreDefault.min.css" />
11 <link type=
"text/css" rel=
"stylesheet" href=
"syntaxhighlighter/styles/shThemejqPlot.min.css" />
13 <!--[if lt IE 9]><script language="javascript" type="text/javascript" src="../excanvas.js"></script><![endif]-->
14 <script class="include" type="text/javascript" src="../jquery.min.js"></script>
21 <a class="nav" href="../../../index.php"><span>></span>Home</a>
22 <a class="nav" href="../../../docs/"><span>></span>Docs</a>
23 <a class="nav" href="../../download/"><span>></span>Download</a>
24 <a class="nav" href="../../../info.php"><span>></span>Info</a>
25 <a class="nav" href="../../../donate.php"><span>></span>Donate</a>
28 <div class="example-content">
30 <div class="example-nav">
31 <a href="kcp_cdf.html">Previous</a> <a href="./">Examples</a> <a href="kcp_lorenz.html">Next</a></div>
34 <!-- Example scripts go here -->
37 <link class="include" type="text/css" href="jquery-ui/css/smoothness/jquery-ui.min.css" rel="Stylesheet" />
39 <style type="text/css">
42 border: 1px solid darkblue;
43 padding: 30px 0px 30px 30px;
49 table.jqplot-table-legend {
52 margin: 0px 0px 10px 15px;
55 td.jqplot-table-legend-label {
59 div.jqplot-table-legend-swatch {
60 border-width: 1.5px 6px;
63 div.jqplot-table-legend-swatch-outline {
84 list-style-type: none;
99 <div class="chart-container">
100 <div id="chart1"></div>
101 <div class="jqplot-datestamp"></div>
104 <pre class="code brush:js"></pre>
106 <script class="code" type="text/javascript">
107 $(document).ready(function(){
110 // This is NOT a full csv parser.
111 // It does not handle quoated text.
112 // It is for demonstration only.
113 // For a full featured csv parser, look at:
115 // http://www.bennadel.com/blog/1504-Ask-Ben-Parsing-CSV-Strings-With-Javascript-Exec-Regular-Expression-Command.htm
118 var parseCSVFile = function(url) {
125 // have to use synchronous here, else returns before data is fetched
129 success: function(data) {
131 var lines = data.split('\n');
133 for (var i=0, l=lines.length; i<l; i++) {
134 line = lines[i].replace('\r', '').split(',');
135 // console.log(line);
136 if (line.length > 1) {
138 ticks = line.slice(1, line.length);
141 labels.push(line[0]);
142 values.push(line.slice(1, line.length));
143 temp = values[values.length-1];
145 values[values.length-1][n] = parseFloat(temp[n]);
150 ret = [values, labels, ticks];
156 var jsonurl = "./KCPsample4.csv";
158 var infos = parseCSVFile(jsonurl);
160 var labels = infos[1];
161 var ticks = infos[2];
165 plot1 = $.jqplot("chart1", data, {
166 title: "Engel Curves",
169 labelRenderer: $.jqplot.CanvasAxisLabelRenderer
176 renderer: $.jqplot.EnhancedLegendRenderer,
177 placement: "outsideGrid",
182 // set to true to replot when toggling series on/off
183 // set to an options object to pass in replot options.
184 seriesToggle: 'normal',
185 seriesToggleReplot: {resetAxes: true}
190 label: 'Population Percentile',
197 label: 'Share in Total Expenditure (%)',
208 // background: 'rgba(0,0,0,0)' works to make transparent.
213 // add a date at the bottom.
215 var d = new $.jsDate();
216 $("div.jqplot-datestamp").html("Generated on "+d.strftime("%v"));
218 // make it resizable.
220 $("div.chart-container").resizable({delay:20});
222 $("div.chart-container").bind("resize", function(event, ui) {
230 <!-- End example scripts -->
232 <!-- Don't touch this! -->
235 <script class="include" type="text/javascript" src="../jquery.jqplot.min.js"></script>
236 <script type="text/javascript" src="syntaxhighlighter/scripts/shCore.min.js"></script>
237 <script type="text/javascript" src="syntaxhighlighter/scripts/shBrushJScript.min.js"></script>
238 <script type="text/javascript" src="syntaxhighlighter/scripts/shBrushXml.min.js"></script>
239 <!-- End Don't touch this! -->
241 <!-- Additional plugins go here -->>
242 <script class="include" type="text/javascript" src="../plugins/jqplot.canvasTextRenderer.min.js"></script>
243 <script class="include" type="text/javascript" src="../plugins/jqplot.canvasAxisLabelRenderer.min.js"></script>
244 <script class="include" type="text/javascript" src="../plugins/jqplot.enhancedLegendRenderer.min.js"></script>
245 <script class="include" type="text/javascript" src="jquery-ui/js/jquery-ui.min.js"></script>
247 <!-- End additional plugins -->
251 <script type="text/javascript" src="example.min.js"></script>