[build][s]: regular build.
This commit is contained in:
79
dist/recline.js
vendored
79
dist/recline.js
vendored
@@ -1871,25 +1871,17 @@ my.Flot = Backbone.View.extend({
|
|||||||
},
|
},
|
||||||
|
|
||||||
_xaxisLabel: function (x) {
|
_xaxisLabel: function (x) {
|
||||||
var xfield = this.model.fields.get(this.state.attributes.group);
|
if (this._groupFieldIsDateTime()) {
|
||||||
|
// oddly x comes through as milliseconds *string* (rather than int
|
||||||
// time series
|
// or float) so we have to reparse
|
||||||
var xtype = xfield.get('type');
|
x = new Date(parseFloat(x)).toLocaleDateString();
|
||||||
var isDateTime = (xtype === 'date' || xtype === 'date-time' || xtype === 'time');
|
} else if (this.xvaluesAreIndex) {
|
||||||
|
|
||||||
if (this.xvaluesAreIndex) {
|
|
||||||
x = parseInt(x, 10);
|
x = parseInt(x, 10);
|
||||||
// HACK: deal with bar graph style cases where x-axis items were strings
|
// HACK: deal with bar graph style cases where x-axis items were strings
|
||||||
// In this case x at this point is the index of the item in the list of
|
// In this case x at this point is the index of the item in the list of
|
||||||
// records not its actual x-axis value
|
// records not its actual x-axis value
|
||||||
x = this.model.records.models[x].get(this.state.attributes.group);
|
x = this.model.records.models[x].get(this.state.attributes.group);
|
||||||
}
|
}
|
||||||
if (isDateTime) {
|
|
||||||
x = new Date(x).toLocaleDateString();
|
|
||||||
}
|
|
||||||
// } else if (isDateTime) {
|
|
||||||
// x = new Date(parseInt(x, 10)).toLocaleDateString();
|
|
||||||
// }
|
|
||||||
|
|
||||||
return x;
|
return x;
|
||||||
},
|
},
|
||||||
@@ -1904,25 +1896,26 @@ my.Flot = Backbone.View.extend({
|
|||||||
// @param numPoints the number of points that will be plotted
|
// @param numPoints the number of points that will be plotted
|
||||||
getGraphOptions: function(typeId, numPoints) {
|
getGraphOptions: function(typeId, numPoints) {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
var groupFieldIsDateTime = self._groupFieldIsDateTime();
|
||||||
var tickFormatter = function (x) {
|
|
||||||
// convert x to a string and make sure that it is not too long or the
|
|
||||||
// tick labels will overlap
|
|
||||||
// TODO: find a more accurate way of calculating the size of tick labels
|
|
||||||
var label = self._xaxisLabel(x) || "";
|
|
||||||
|
|
||||||
if (typeof label !== 'string') {
|
|
||||||
label = label.toString();
|
|
||||||
}
|
|
||||||
if (self.state.attributes.graphType !== 'bars' && label.length > 10) {
|
|
||||||
label = label.slice(0, 10) + "...";
|
|
||||||
}
|
|
||||||
|
|
||||||
return label;
|
|
||||||
};
|
|
||||||
|
|
||||||
var xaxis = {};
|
var xaxis = {};
|
||||||
xaxis.tickFormatter = tickFormatter;
|
|
||||||
|
if (!groupFieldIsDateTime) {
|
||||||
|
xaxis.tickFormatter = function (x) {
|
||||||
|
// convert x to a string and make sure that it is not too long or the
|
||||||
|
// tick labels will overlap
|
||||||
|
// TODO: find a more accurate way of calculating the size of tick labels
|
||||||
|
var label = self._xaxisLabel(x) || "";
|
||||||
|
|
||||||
|
if (typeof label !== 'string') {
|
||||||
|
label = label.toString();
|
||||||
|
}
|
||||||
|
if (self.state.attributes.graphType !== 'bars' && label.length > 10) {
|
||||||
|
label = label.slice(0, 10) + "...";
|
||||||
|
}
|
||||||
|
|
||||||
|
return label;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
// for labels case we only want ticks at the label intervals
|
// for labels case we only want ticks at the label intervals
|
||||||
// HACK: however we also get this case with Date fields. In that case we
|
// HACK: however we also get this case with Date fields. In that case we
|
||||||
@@ -1935,6 +1928,8 @@ my.Flot = Backbone.View.extend({
|
|||||||
ticks.push(parseInt(i*increment, 10));
|
ticks.push(parseInt(i*increment, 10));
|
||||||
}
|
}
|
||||||
xaxis.ticks = ticks;
|
xaxis.ticks = ticks;
|
||||||
|
} else if (groupFieldIsDateTime) {
|
||||||
|
xaxis.mode = 'time';
|
||||||
}
|
}
|
||||||
|
|
||||||
var yaxis = {};
|
var yaxis = {};
|
||||||
@@ -2016,24 +2011,32 @@ my.Flot = Backbone.View.extend({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
_groupFieldIsDateTime: function() {
|
||||||
|
var xfield = this.model.fields.get(this.state.attributes.group);
|
||||||
|
var xtype = xfield.get('type');
|
||||||
|
var isDateTime = (xtype === 'date' || xtype === 'date-time' || xtype === 'time');
|
||||||
|
return isDateTime;
|
||||||
|
},
|
||||||
|
|
||||||
createSeries: function() {
|
createSeries: function() {
|
||||||
var self = this;
|
var self = this;
|
||||||
self.xvaluesAreIndex = false;
|
self.xvaluesAreIndex = false;
|
||||||
var series = [];
|
var series = [];
|
||||||
|
var xfield = self.model.fields.get(self.state.attributes.group);
|
||||||
|
var isDateTime = self._groupFieldIsDateTime();
|
||||||
|
|
||||||
_.each(this.state.attributes.series, function(field) {
|
_.each(this.state.attributes.series, function(field) {
|
||||||
var points = [];
|
var points = [];
|
||||||
var fieldLabel = self.model.fields.get(field).get('label');
|
var fieldLabel = self.model.fields.get(field).get('label');
|
||||||
_.each(self.model.records.models, function(doc, index) {
|
_.each(self.model.records.models, function(doc, index) {
|
||||||
var xfield = self.model.fields.get(self.state.attributes.group);
|
|
||||||
var x = doc.getFieldValue(xfield);
|
var x = doc.getFieldValue(xfield);
|
||||||
|
|
||||||
// time series
|
|
||||||
var xtype = xfield.get('type');
|
|
||||||
var isDateTime = (xtype === 'date' || xtype === 'date-time' || xtype === 'time');
|
|
||||||
|
|
||||||
if (isDateTime) {
|
if (isDateTime) {
|
||||||
self.xvaluesAreIndex = true;
|
// cast to string as Date(1990) produces 1970 date but Date('1990') produces 1/1/1990
|
||||||
x = index;
|
var _date = moment(String(x));
|
||||||
|
if (_date.isValid()) {
|
||||||
|
x = _date.toDate().getTime();
|
||||||
|
}
|
||||||
} else if (typeof x === 'string') {
|
} else if (typeof x === 'string') {
|
||||||
x = parseFloat(x);
|
x = parseFloat(x);
|
||||||
if (isNaN(x)) { // assume this is a string label
|
if (isNaN(x)) { // assume this is a string label
|
||||||
|
|||||||
Reference in New Issue
Block a user