Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/phpmyadmin/phpmyadmin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMadhura Jayaratne <madhura.cj@gmail.com>2013-01-14 22:48:05 +0400
committerMadhura Jayaratne <madhura.cj@gmail.com>2013-01-14 22:48:05 +0400
commit34c676c1d146a9e0a45d1dd46afe19fb4cfd9c94 (patch)
tree193da239671ad201f87cae44551a46d9ef8e1cb0 /js/chart.js
parent37a7aa920634d2b1d392cb88a5c390152bba2b44 (diff)
Draw timeline charts with queries
Diffstat (limited to 'js/chart.js')
-rw-r--r--js/chart.js48
1 files changed, 47 insertions, 1 deletions
diff --git a/js/chart.js b/js/chart.js
index f5cba81792..be1604f1ed 100644
--- a/js/chart.js
+++ b/js/chart.js
@@ -6,7 +6,8 @@ var ChartType = {
AREA : 'area',
BAR : 'bar',
COLUMN : 'column',
- PIE : 'pie'
+ PIE : 'pie',
+ TIMELINE: 'timeline'
};
/**
@@ -161,6 +162,9 @@ JQPlotChartFactory.prototype.createChart = function(type, elementId) {
case ChartType.LINE:
chart = new JQPlotLineChart(elementId);
break;
+ case ChartType.TIMELINE:
+ chart = new JQPloatTimelineChart(elementId);
+ break;
case ChartType.AREA:
chart = new JQPlotAreaChart(elementId);
break;
@@ -298,6 +302,48 @@ JQPlotLineChart.prototype.prepareData = function(dataTable) {
};
/**
+ * JQPlot timeline chart
+ *
+ * @param elementId
+ * id of the div element the chart is drawn in
+ */
+var JQPloatTimelineChart = function(elementId) {
+ JQPlotLineChart.call(this, elementId);
+};
+JQPloatTimelineChart.prototype = new JQPlotLineChart();
+JQPloatTimelineChart.prototype.constructor = JQPlotAreaChart;
+
+JQPloatTimelineChart.prototype.populateOptions = function(dataTable, options) {
+ var opt = JQPlotLineChart.prototype.populateOptions.call(this, dataTable,
+ options);
+ opt.axes.xaxis.renderer = $.jqplot.DateAxisRenderer;
+ opt.axes.xaxis.tickOptions = {
+ formatString:'%b %#d, %y'
+ };
+ return opt;
+};
+
+JQPloatTimelineChart.prototype.prepareData = function(dataTable) {
+ var data = dataTable.getData(), row, d;
+ var retData = [], retRow;
+ for ( var i = 0; i < data.length; i++) {
+ row = data[i];
+ d = row[0];
+ for ( var j = 1; j < row.length; j++) {
+ retRow = retData[j - 1];
+ if (retRow == null) {
+ retRow = [];
+ retData[j - 1] = retRow;
+ }
+ if (d != null) {
+ retRow.push([d.getTime(), row[j]]);
+ }
+ }
+ }
+ return retData;
+};
+
+/**
* JQPlot area chart
*
* @param elementId