Merge branch 'master' of github.com:okfn/recline
This commit is contained in:
@@ -59,7 +59,7 @@ For larger changes:
|
|||||||
* [Max Ogden](http://maxogden.com/)
|
* [Max Ogden](http://maxogden.com/)
|
||||||
* [John Glover](https://github.com/johnglover)
|
* [John Glover](https://github.com/johnglover)
|
||||||
* [James Casbon](http://casbon.me/)
|
* [James Casbon](http://casbon.me/)
|
||||||
* [Adria Mercader](http://amercader.net/)
|
* [Adrià Mercader](http://amercader.net/)
|
||||||
* [Dominik Moritz](https://github.com/domoritz)
|
* [Dominik Moritz](https://github.com/domoritz)
|
||||||
* [Friedrich Lindenberg](http://pudo.org/)
|
* [Friedrich Lindenberg](http://pudo.org/)
|
||||||
* And [many more](https://github.com/okfn/recline/graphs/contributors)
|
* And [many more](https://github.com/okfn/recline/graphs/contributors)
|
||||||
|
|||||||
@@ -15,7 +15,8 @@ this.recline.View = this.recline.View || {};
|
|||||||
// {
|
// {
|
||||||
// group: {column name for x-axis},
|
// group: {column name for x-axis},
|
||||||
// series: [{column name for series A}, {column name series B}, ... ],
|
// series: [{column name for series A}, {column name series B}, ... ],
|
||||||
// graphType: 'line'
|
// graphType: 'line',
|
||||||
|
// graphOptions: {custom [flot options]}
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// NB: should *not* provide an el argument to the view but must let the view
|
// NB: should *not* provide an el argument to the view but must let the view
|
||||||
@@ -259,22 +260,43 @@ my.Flot = Backbone.View.extend({
|
|||||||
grid: grid
|
grid: grid
|
||||||
},
|
},
|
||||||
bars: {
|
bars: {
|
||||||
|
legend: legend,
|
||||||
|
colors: this.graphColors,
|
||||||
|
lines: { show: false },
|
||||||
|
xaxis: yaxis,
|
||||||
|
yaxis: xaxis,
|
||||||
|
grid: grid,
|
||||||
|
bars: {
|
||||||
|
show: true,
|
||||||
|
horizontal: true,
|
||||||
|
shadowSize: 0,
|
||||||
|
align: 'center',
|
||||||
|
barWidth: 0.8
|
||||||
|
}
|
||||||
|
},
|
||||||
|
columns: {
|
||||||
legend: legend,
|
legend: legend,
|
||||||
colors: this.graphColors,
|
colors: this.graphColors,
|
||||||
lines: { show: false },
|
lines: { show: false },
|
||||||
xaxis: xaxis,
|
xaxis: xaxis,
|
||||||
yaxis: yaxis,
|
yaxis: yaxis,
|
||||||
|
grid: grid,
|
||||||
bars: {
|
bars: {
|
||||||
show: true,
|
show: true,
|
||||||
horizontal: false,
|
horizontal: false,
|
||||||
shadowSize: 0,
|
shadowSize: 0,
|
||||||
align: 'center',
|
align: 'center',
|
||||||
barWidth: 0.8
|
barWidth: 0.8
|
||||||
},
|
}
|
||||||
grid: grid
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
return optionsPerGraphType[typeId];
|
|
||||||
|
if (self.state.get('graphOptions')) {
|
||||||
|
return _.extend(optionsPerGraphType[typeId],
|
||||||
|
self.state.get('graphOptions'));
|
||||||
|
} else {
|
||||||
|
return optionsPerGraphType[typeId];
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
createSeries: function() {
|
createSeries: function() {
|
||||||
@@ -291,20 +313,27 @@ my.Flot = Backbone.View.extend({
|
|||||||
var isDateTime = (xtype === 'date' || xtype === 'date-time' || xtype === 'time');
|
var isDateTime = (xtype === 'date' || xtype === 'date-time' || xtype === 'time');
|
||||||
|
|
||||||
if (isDateTime) {
|
if (isDateTime) {
|
||||||
// datetime
|
if (self.state.attributes.graphType != 'bars' &&
|
||||||
if (self.state.attributes.graphType != 'bars') {
|
self.state.attributes.graphType != 'columns') {
|
||||||
x = new Date(x).getTime();
|
x = new Date(x).getTime();
|
||||||
} else {
|
} else {
|
||||||
x = index;
|
x = index;
|
||||||
}
|
}
|
||||||
} else if (typeof x === 'string') {
|
} else if (typeof x === 'string') {
|
||||||
x = index;
|
x = parseFloat(x);
|
||||||
|
if (isNaN(x)) {
|
||||||
|
x = index;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var yfield = self.model.fields.get(field);
|
var yfield = self.model.fields.get(field);
|
||||||
var y = doc.getFieldValue(yfield);
|
var y = doc.getFieldValue(yfield);
|
||||||
|
|
||||||
points.push([x, y]);
|
if (self.state.attributes.graphType == 'bars') {
|
||||||
|
points.push([y, x]);
|
||||||
|
} else {
|
||||||
|
points.push([x, y]);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
series.push({
|
series.push({
|
||||||
data: points,
|
data: points,
|
||||||
@@ -329,9 +358,10 @@ my.FlotControls = Backbone.View.extend({
|
|||||||
<option value="lines">Lines</option> \
|
<option value="lines">Lines</option> \
|
||||||
<option value="points">Points</option> \
|
<option value="points">Points</option> \
|
||||||
<option value="bars">Bars</option> \
|
<option value="bars">Bars</option> \
|
||||||
|
<option value="columns">Columns</option> \
|
||||||
</select> \
|
</select> \
|
||||||
</div> \
|
</div> \
|
||||||
<label>X-Axis</label> \
|
<label>Group Column (Axis 1)</label> \
|
||||||
<div class="input editor-group"> \
|
<div class="input editor-group"> \
|
||||||
<select> \
|
<select> \
|
||||||
<option value="">Please choose ...</option> \
|
<option value="">Please choose ...</option> \
|
||||||
@@ -344,7 +374,7 @@ my.FlotControls = Backbone.View.extend({
|
|||||||
</div> \
|
</div> \
|
||||||
</div> \
|
</div> \
|
||||||
<div class="editor-buttons"> \
|
<div class="editor-buttons"> \
|
||||||
<button class="btn editor-add">Add Additional Y-Axis Plot</button> \
|
<button class="btn editor-add">Add Series</button> \
|
||||||
</div> \
|
</div> \
|
||||||
<div class="editor-buttons editor-submit" comment="hidden temporarily" style="display: none;"> \
|
<div class="editor-buttons editor-submit" comment="hidden temporarily" style="display: none;"> \
|
||||||
<button class="editor-save">Save</button> \
|
<button class="editor-save">Save</button> \
|
||||||
@@ -355,7 +385,7 @@ my.FlotControls = Backbone.View.extend({
|
|||||||
',
|
',
|
||||||
templateSeriesEditor: ' \
|
templateSeriesEditor: ' \
|
||||||
<div class="editor-series js-series-{{seriesIndex}}"> \
|
<div class="editor-series js-series-{{seriesIndex}}"> \
|
||||||
<label>Y-Axis (<span>{{seriesName}})</span> \
|
<label>Series <span>{{seriesName}} (Axis 2)</span> \
|
||||||
[<a href="#remove" class="action-remove-series">Remove</a>] \
|
[<a href="#remove" class="action-remove-series">Remove</a>] \
|
||||||
</label> \
|
</label> \
|
||||||
<div class="input"> \
|
<div class="input"> \
|
||||||
@@ -470,4 +500,3 @@ my.FlotControls = Backbone.View.extend({
|
|||||||
});
|
});
|
||||||
|
|
||||||
})(jQuery, recline.View);
|
})(jQuery, recline.View);
|
||||||
|
|
||||||
|
|||||||
@@ -320,7 +320,7 @@ my.GraphControls = Backbone.View.extend({
|
|||||||
<option value="columns">Columns</option> \
|
<option value="columns">Columns</option> \
|
||||||
</select> \
|
</select> \
|
||||||
</div> \
|
</div> \
|
||||||
<label>Group Column (x-axis)</label> \
|
<label>Group Column (Axis 1)</label> \
|
||||||
<div class="input editor-group"> \
|
<div class="input editor-group"> \
|
||||||
<select> \
|
<select> \
|
||||||
<option value="">Please choose ...</option> \
|
<option value="">Please choose ...</option> \
|
||||||
@@ -344,7 +344,7 @@ my.GraphControls = Backbone.View.extend({
|
|||||||
',
|
',
|
||||||
templateSeriesEditor: ' \
|
templateSeriesEditor: ' \
|
||||||
<div class="editor-series js-series-{{seriesIndex}}"> \
|
<div class="editor-series js-series-{{seriesIndex}}"> \
|
||||||
<label>Series <span>{{seriesName}} (y-axis)</span> \
|
<label>Series <span>{{seriesName}} (Axis 2)</span> \
|
||||||
[<a href="#remove" class="action-remove-series">Remove</a>] \
|
[<a href="#remove" class="action-remove-series">Remove</a>] \
|
||||||
</label> \
|
</label> \
|
||||||
<div class="input"> \
|
<div class="input"> \
|
||||||
|
|||||||
Reference in New Issue
Block a user