Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 38 additions & 3 deletions zeppelin-web/app/scripts/controllers/paragraph.js
Original file line numberDiff line numberDiff line change
Expand Up@@ -817,6 +817,8 @@ angular.module('zeppelinWebApp')

var d3g = [];

// console.log('data is\n %s \n', JSON.stringify(data));

if (type === 'scatterChart') {
var scatterData = setScatterChart(data, refresh);

Expand DownExpand Up@@ -857,6 +859,8 @@ angular.module('zeppelinWebApp')
.scatter.useVoronoi(false);
} else {
var p = pivot(data);
// console.log('Pivot(data) is\n %s \n', JSON.stringify(p));

if (type === 'pieChart') {
var d = pivotDataToD3ChartFormat(p, true).d3g;

Expand DownExpand Up@@ -890,6 +894,9 @@ angular.module('zeppelinWebApp')
$scope.chart[type].useInteractiveGuideline(true); // for better UX and performance issue. (https://github.com/novus/nvd3/issues/691)
$scope.chart[type].forceY([0]); // force y-axis minimum to 0 for line chart.
}

// console.log('pivotDataD3ChartFormat is %s', JSON.stringify(d3g));

}

var renderChart = function() {
Expand DownExpand Up@@ -1117,6 +1124,10 @@ angular.module('zeppelinWebApp')
avg : true
};

var getIndex = function(previous, actual) {
return (previous === null || typeof(previous) === 'undefined' ) ? actual : Math.min(previous, actual);
};

var schema = {};
var rows = {};

Expand DownExpand Up@@ -1146,6 +1157,7 @@ angular.module('zeppelinWebApp')
p[keyKey] = {};
}
p = p[keyKey];
p.rowIndex = getIndex(p.rowIndex, i);
}

for (var g=0; g < groups.length; g++) {
Expand All@@ -1168,6 +1180,9 @@ angular.module('zeppelinWebApp')
p[groupKey] = {};
}
p = p[groupKey];
if (keys.length == 0) {
p.rowIndex = getIndex(p.rowIndex, i);
}
}

for (var v=0; v < values.length; v++) {
Expand DownExpand Up@@ -1195,14 +1210,32 @@ angular.module('zeppelinWebApp')
count : (aggrFuncDiv[value.aggr]) ? p[valueKey].count+1 : p[valueKey].count
};
}
if (keys.length == 0 && groups.length == 0) {
p.idx = getIndex(p.idx, v );
}
}
}

var compareRowIndex = function(a,b) {
var ai = a[Object.keys(a)[0]].rowIndex;
var bi = b[Object.keys(b)[0]].rowIndex;
if (ai < bi) { return -1; }
else if (ai > bi) { return 1; }
else { return 0; }
};
var rowsArray = [];
for (var key in rows) {
var e = {};
e[key] = rows[key];
rowsArray.push(e);
};
rowsArray.sort(compareRowIndex);

//console.log("schema=%o, rows=%o", schema, rows);

return {
schema : schema,
rows : rows
rows : rowsArray
};
};

Expand DownExpand Up@@ -1273,8 +1306,10 @@ angular.module('zeppelinWebApp')
var colIdx = 0;
var rowIndexValue = {};

for (var k in rows) {
traverse(sKey, schema[sKey], k, rows[k], function(rowName, rowValue, colName, value) {
for (var kk in rows) {
var row = rows[kk];
var k = Object.keys(row)[0];
traverse(sKey, schema[sKey], k, row[k], function(rowName, rowValue, colName, value) {
//console.log("RowName=%o, row=%o, col=%o, value=%o", rowName, rowValue, colName, value);
if (rowNameIndex[rowValue] === undefined) {
rowIndexValue[rowIdx] = rowValue;
Expand Down