mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-17 13:33:15 +01:00
f8489c0ed1
jquery.jqplot.1.0.0b2_r947
229 lines
6.1 KiB
HTML
229 lines
6.1 KiB
HTML
<!DOCTYPE html>
|
|
|
|
<html lang="en">
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
|
<!-- Use Compatibility mode in IE -->
|
|
<title>Area Chart</title>
|
|
<!--[if lt IE 9]><script language="javascript" type="text/javascript" src="../excanvas.js"></script><![endif]-->
|
|
|
|
<link rel="stylesheet" type="text/css" href="../jquery.jqplot.min.css" />
|
|
<link rel="stylesheet" type="text/css" href="../examples/examples.css" />
|
|
|
|
<!-- BEGIN: load jquery -->
|
|
<script language="javascript" type="text/javascript" src="../jquery.min.js"></script>
|
|
<!-- END: load jquery -->
|
|
|
|
<!-- BEGIN: load jqplot -->
|
|
<script language="javascript" type="text/javascript" src="../jquery.jqplot.min.js"></script>
|
|
|
|
<link type="text/css" href="jquery-ui/css/ui-lightness/jquery-ui.min.css" rel="Stylesheet" />
|
|
<script type="text/javascript" src="jquery-ui/js/jquery-ui.min.js"></script>
|
|
<!-- END: load jqplot -->
|
|
|
|
<style type="text/css">
|
|
|
|
.chart-container {
|
|
border: 1px solid darkblue;
|
|
padding: 30px 0px 30px 30px;
|
|
width: 900px;
|
|
height: 400px;
|
|
|
|
}
|
|
|
|
table.jqplot-table-legend {
|
|
font-size: 0.65em;
|
|
line-height: 1em;
|
|
margin: 0px 0px 10px 15px;
|
|
}
|
|
|
|
td.jqplot-table-legend-label {
|
|
width: 20em;
|
|
}
|
|
|
|
div.jqplot-table-legend-swatch {
|
|
border-width: 2px 6px;
|
|
}
|
|
|
|
div.jqplot-table-legend-swatch-outline {
|
|
border: none;
|
|
}
|
|
|
|
#chart1 {
|
|
width: 96%;
|
|
height: 96%;
|
|
}
|
|
|
|
.jqplot-datestamp {
|
|
font-size: 0.8em;
|
|
color: #777;
|
|
/* margin-top: 1em;
|
|
text-align: right;*/
|
|
font-style: italic;
|
|
position: absolute;
|
|
bottom: 15px;
|
|
right: 15px;
|
|
}
|
|
|
|
td.controls li {
|
|
list-style-type: none;
|
|
}
|
|
|
|
td.controls ul {
|
|
margin-top: 0.5em;
|
|
padding-left: 0.2em;
|
|
}
|
|
|
|
pre.code {
|
|
margin-top: 45px;
|
|
clear: both;
|
|
}
|
|
|
|
</style>
|
|
|
|
<script class="code" type="text/javascript">
|
|
$(document).ready(function(){
|
|
|
|
///////////
|
|
// Function to parse a csv file.
|
|
// Note, this IS NOT a complete parser. It does not handle quoted text.
|
|
// It is implemented to demonstrate functionality from within JavaScript.
|
|
// If a full csv parser is needed, check out:
|
|
// http://www.bennadel.com/blog/1504-Ask-Ben-Parsing-CSV-Strings-With-Javascript-Exec-Regular-Expression-Command.htm
|
|
///////////
|
|
var parseCSVFile = function(url) {
|
|
var ret = null;
|
|
var labels = [];
|
|
var ticks = [];
|
|
var values = [];
|
|
var temp;
|
|
$.ajax({
|
|
// have to use synchronous here, else returns before data is fetched
|
|
async: false,
|
|
url: url,
|
|
dataType:'text',
|
|
success: function(data) {
|
|
// parse csv data
|
|
var lines = data.split('\n');
|
|
var line;
|
|
for (var i=0, l=lines.length; i<l; i++) {
|
|
line = lines[i].replace('\r', '').split(',');
|
|
// console.log(line);
|
|
if (line.length > 1) {
|
|
if (i === 0) {
|
|
ticks = line.slice(1, line.length);
|
|
for (var n=0, nl=ticks.length; n<nl; n++) {
|
|
ticks[n] = [n+1, ticks[n]];
|
|
}
|
|
}
|
|
else {
|
|
labels.push(line[0]);
|
|
values.push(line.slice(1, line.length));
|
|
temp = values[values.length-1];
|
|
// make a copy of temp
|
|
temp = temp.slice(0, temp.length);
|
|
for (var n=0, nl=temp.length; n<nl; n++) {
|
|
values[values.length-1][n] = parseFloat(temp[n]);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
ret = [values, labels, ticks];
|
|
}
|
|
});
|
|
return ret;
|
|
};
|
|
|
|
var jsonurl = "./KCPsample4.csv";
|
|
|
|
var infos = parseCSVFile(jsonurl);
|
|
|
|
// area plots are made with all series except last 2
|
|
data = infos[0].slice(0, infos[0].length-2);
|
|
labels = infos[1].slice(0, infos[1].length-2);
|
|
ticks = infos[2];
|
|
|
|
// make the plot
|
|
|
|
plot1 = $.jqplot('chart1', data, {
|
|
title: 'Area Plot',
|
|
stackSeries: true,
|
|
seriesDefaults: {
|
|
showMarker: false,
|
|
fill: true,
|
|
fillAndStroke: true
|
|
},
|
|
legend: {
|
|
show: true,
|
|
placement: 'outsideGrid',
|
|
labels: labels,
|
|
location: 'ne',
|
|
rowSpacing: '0px'
|
|
},
|
|
axes: {
|
|
xaxis: {
|
|
pad: 0,
|
|
ticks: ticks,
|
|
tickOptions: {
|
|
showGridline: false
|
|
}
|
|
},
|
|
yaxis: {
|
|
min: 0,
|
|
max: 100,
|
|
tickOptions: {
|
|
showGridline: false
|
|
}
|
|
}
|
|
},
|
|
grid: {
|
|
drawBorder: false,
|
|
shadow: false,
|
|
// background: 'rgba(0,0,0,0)' works to make transparent.
|
|
background: 'white'
|
|
}
|
|
});
|
|
|
|
// add a date at the bottom.
|
|
|
|
var d = new $.jsDate();
|
|
$('div.jqplot-datestamp').html('Generated on '+d.strftime('%v'));
|
|
|
|
// make it resizable.
|
|
|
|
$("div.chart-container").resizable({delay:20});
|
|
|
|
$('div.chart-container').bind('resize', function(event, ui) {
|
|
plot1.replot();
|
|
});
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
<script type="text/javascript">
|
|
$(document).ready(function(){
|
|
$('script.code').each(function(index) {
|
|
$('pre.code').eq(index).text($(this).html());
|
|
});
|
|
$(document).unload(function() {$('*').unbind(); });
|
|
});
|
|
</script>
|
|
|
|
</head>
|
|
<body>
|
|
<?php include "topbanner.inc"; ?>
|
|
<div class="example-content">
|
|
<?php include "nav.inc"; ?>
|
|
|
|
<div class="chart-container">
|
|
<div id="chart1"></div>
|
|
<div class="jqplot-datestamp"></div>
|
|
</div>
|
|
|
|
<pre class="code"></pre>
|
|
|
|
|
|
</div>
|
|
</body>
|
|
</html> |