mirror of https://gitee.com/bigwinds/arangodb
fixed bug in nv.d3.js + added labels for dashboard graphs
This commit is contained in:
parent
1c78a2b983
commit
473dfd8adf
|
@ -563,7 +563,8 @@ nv.models.axis = function() {
|
||||||
axisLabel.enter().append('text').attr('class', 'nv-axislabel')
|
axisLabel.enter().append('text').attr('class', 'nv-axislabel')
|
||||||
.attr('text-anchor', rotateYLabel ? 'middle' : 'end')
|
.attr('text-anchor', rotateYLabel ? 'middle' : 'end')
|
||||||
.attr('transform', rotateYLabel ? 'rotate(-90)' : '')
|
.attr('transform', rotateYLabel ? 'rotate(-90)' : '')
|
||||||
.attr('y', rotateYLabel ? (-Math.max(margin.left,width) + 12) : -10); //TODO: consider calculating this based on largest tick width... OR at least expose this on chart
|
//Edited 25 in next line -> origin was 12
|
||||||
|
.attr('y', rotateYLabel ? (-Math.max(margin.left,width) + 28) : -10); //TODO: consider calculating this based on largest tick width... OR at least expose this on chart
|
||||||
axisLabel
|
axisLabel
|
||||||
.attr('x', rotateYLabel ? (-scale.range()[0] / 2) : -axis.tickPadding());
|
.attr('x', rotateYLabel ? (-scale.range()[0] / 2) : -axis.tickPadding());
|
||||||
if (showMaxMin) {
|
if (showMaxMin) {
|
||||||
|
|
|
@ -62,6 +62,7 @@ var dashboardView = Backbone.View.extend({
|
||||||
renderCharts: function () {
|
renderCharts: function () {
|
||||||
var self = this;
|
var self = this;
|
||||||
this.generateClientData();
|
this.generateClientData();
|
||||||
|
var label;
|
||||||
|
|
||||||
$.each(self.clients, function(key, client) {
|
$.each(self.clients, function(key, client) {
|
||||||
var client = client;
|
var client = client;
|
||||||
|
@ -71,8 +72,14 @@ var dashboardView = Backbone.View.extend({
|
||||||
chart.xAxis
|
chart.xAxis
|
||||||
.axisLabel('Time')
|
.axisLabel('Time')
|
||||||
|
|
||||||
|
$.each(self.options.description.models[0].attributes.figures, function(k,v) {
|
||||||
|
if (v.identifier === client) {
|
||||||
|
label = v.units;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
chart.yAxis
|
chart.yAxis
|
||||||
.axisLabel('Values')
|
.axisLabel(label)
|
||||||
|
|
||||||
d3.select("#"+client+"Chart svg")
|
d3.select("#"+client+"Chart svg")
|
||||||
.datum(self.generateD3Input(self.convertedData[client], client, "#8AA051"))
|
.datum(self.generateD3Input(self.convertedData[client], client, "#8AA051"))
|
||||||
|
@ -93,16 +100,21 @@ var dashboardView = Backbone.View.extend({
|
||||||
var self = this;
|
var self = this;
|
||||||
this.generateClientData();
|
this.generateClientData();
|
||||||
|
|
||||||
|
var label;
|
||||||
|
|
||||||
$.each(self.clients, function(key, client) {
|
$.each(self.clients, function(key, client) {
|
||||||
var client = client;
|
var client = client;
|
||||||
|
|
||||||
var chart = nv.models.lineChart();
|
var chart = nv.models.lineChart();
|
||||||
|
|
||||||
chart.xAxis
|
chart.xAxis
|
||||||
.axisLabel("Time (ms)")
|
.axisLabel("Time (ms)")
|
||||||
|
$.each(self.options.description.models[0].attributes.figures, function(k,v) {
|
||||||
|
if (v.identifier === client) {
|
||||||
|
label = v.units;
|
||||||
|
}
|
||||||
|
});
|
||||||
chart.yAxis
|
chart.yAxis
|
||||||
.axisLabel("Values");
|
.axisLabel(label)
|
||||||
|
|
||||||
d3.select("#"+client+"Chart svg")
|
d3.select("#"+client+"Chart svg")
|
||||||
.datum(self.generateD3Input(self.convertedData[client], client, "#8AA051"))
|
.datum(self.generateD3Input(self.convertedData[client], client, "#8AA051"))
|
||||||
|
@ -129,35 +141,36 @@ var dashboardView = Backbone.View.extend({
|
||||||
|
|
||||||
generateClientData: function () {
|
generateClientData: function () {
|
||||||
var self = this;
|
var self = this;
|
||||||
var x = []; //Value
|
var x = []; //Time
|
||||||
var y = []; //Time
|
var y = []; //Value
|
||||||
var tempName;
|
var tempName;
|
||||||
var tempArray = [];
|
var tempArray = [];
|
||||||
$.each(this.collection.models[0].attributes.client, function(key, val) {
|
$.each(this.collection.models[0].attributes.client, function(key, val) {
|
||||||
tempName = key;
|
tempName = key;
|
||||||
if (val.sum === undefined) {
|
if (self.convertedData[tempName] === undefined) {
|
||||||
|
self.convertedData[tempName] = [];
|
||||||
}
|
}
|
||||||
else {
|
if (self.convertedData[tempName].length === 0) {
|
||||||
if (self.convertedData[tempName] === undefined) {
|
self.oldSum[tempName] = val.sum;
|
||||||
self.convertedData[tempName] = [];
|
tempArray = self.convertedData[tempName];
|
||||||
}
|
var timeStamp = Math.round(+new Date()/1000);
|
||||||
if (self.convertedData[tempName].length === 0) {
|
tempArray.push({x:timeStamp, y:0});
|
||||||
self.oldSum[tempName] = val.sum;
|
|
||||||
tempArray = self.convertedData[tempName];
|
|
||||||
var timeStamp = Math.round(+new Date()/1000);
|
|
||||||
tempArray.push({x:timeStamp, y:0});
|
|
||||||
}
|
|
||||||
if (self.convertedData[tempName].length !== 0) {
|
|
||||||
tempArray = self.convertedData[tempName];
|
|
||||||
var calculatedSum = val.sum - self.oldSum[tempName];
|
|
||||||
var timeStamp = Math.round(+new Date()/1000);
|
|
||||||
|
|
||||||
|
|
||||||
self.oldSum[tempName] = val.sum;
|
|
||||||
tempArray.push({x:timeStamp, y:calculatedSum});
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
if (self.convertedData[tempName].length !== 0) {
|
||||||
|
tempArray = self.convertedData[tempName];
|
||||||
|
|
||||||
|
var timeStamp = Math.round(+new Date()/1000);
|
||||||
|
|
||||||
|
if (val.sum === undefined) {
|
||||||
|
tempArray.push({x:timeStamp, y:val});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var calculatedSum = val.sum - self.oldSum[tempName];
|
||||||
|
self.oldSum[tempName] = val.sum;
|
||||||
|
tempArray.push({x:timeStamp, y:calculatedSum});
|
||||||
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -167,10 +180,10 @@ var dashboardView = Backbone.View.extend({
|
||||||
}
|
}
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
values: values,
|
values: values,
|
||||||
key: key,
|
key: key,
|
||||||
color: color
|
color: color
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue