Merge pull request #476 from NuCivic/fix_percentage_values_issue
Fix #475: Allow flot view to graph columns with percentage values
This commit is contained in:
commit
d2640036db
2
dist/recline.js
vendored
2
dist/recline.js
vendored
@ -1381,7 +1381,7 @@ my.Flot = Backbone.View.extend({
|
||||
}
|
||||
|
||||
var yfield = self.model.fields.get(field);
|
||||
var y = doc.getFieldValueUnrendered(yfield);
|
||||
var y = parseFloat(doc.getFieldValueUnrendered(yfield));
|
||||
|
||||
if (self.state.attributes.graphType == 'bars') {
|
||||
points.push([y, x]);
|
||||
|
||||
2
dist/recline.min.js
vendored
2
dist/recline.min.js
vendored
File diff suppressed because one or more lines are too long
@ -622,7 +622,7 @@ could have a lot of values and so we limit to max 15 (we assume)</p>
|
||||
}
|
||||
|
||||
<span class="hljs-keyword">var</span> yfield = self.model.fields.get(field);
|
||||
<span class="hljs-keyword">var</span> y = doc.getFieldValueUnrendered(yfield);
|
||||
<span class="hljs-keyword">var</span> y = <span class="hljs-built_in">parseFloat</span>(doc.getFieldValueUnrendered(yfield));
|
||||
|
||||
<span class="hljs-keyword">if</span> (self.state.attributes.graphType == <span class="hljs-string">'bars'</span>) {
|
||||
points.push([y, x]);
|
||||
|
||||
@ -142,7 +142,7 @@ my.Pager = Backbone.View.extend({
|
||||
<div class="pagination"> \
|
||||
<ul class="pagination"> \
|
||||
<li class="prev action-pagination-update"><a href="" class="btn btn-default">&laquo;</a></li> \
|
||||
<li class="page-range"><a><label for="from">From</label><input name="from" type="text" value="{{from}}" /> &ndash; <label for="to">To</label><input name="to" type="text" value="{{to}}" /> </a></li> \
|
||||
<li class="page-range"><a><label for="from">From</label><input id="from" name="from" type="text" value="{{from}}" /> &ndash; <label for="to">To</label><input id="to" name="to" type="text" value="{{to}}" /> </a></li> \
|
||||
<li class="next action-pagination-update"><a href="" class="btn btn-default">&raquo;</a></li> \
|
||||
</ul> \
|
||||
</div> \
|
||||
|
||||
@ -145,8 +145,8 @@ my.QueryEditor = Backbone.View.extend({
|
||||
<div class="input-group-addon"> \
|
||||
<i class="glyphicon glyphicon-search"></i> \
|
||||
</div> \
|
||||
<label>Search</label> \
|
||||
<input class="form-control search-query" type="text" name="q" value="{{q}}" placeholder="Search data ..."> \
|
||||
<label for="q">Search</label> \
|
||||
<input class="form-control search-query" type="text" id="q" name="q" value="{{q}}" placeholder="Search data ..."> \
|
||||
</div> \
|
||||
</div> \
|
||||
<button type="submit" class="btn btn-default">Go &raquo;</button> \
|
||||
|
||||
@ -343,7 +343,7 @@ my.Flot = Backbone.View.extend({
|
||||
}
|
||||
|
||||
var yfield = self.model.fields.get(field);
|
||||
var y = doc.getFieldValueUnrendered(yfield);
|
||||
var y = parseFloat(doc.getFieldValueUnrendered(yfield));
|
||||
|
||||
if (self.state.attributes.graphType == 'bars') {
|
||||
points.push([y, x]);
|
||||
|
||||
13
test/base.js
13
test/base.js
@ -6,18 +6,19 @@ var Fixture = {
|
||||
{id: 'x'},
|
||||
{id: 'y'},
|
||||
{id: 'z'},
|
||||
{id: 'p'},
|
||||
{id: 'country'},
|
||||
{id: 'title'},
|
||||
{id: 'lat'},
|
||||
{id: 'lon'}
|
||||
];
|
||||
var documents = [
|
||||
{id: 0, date: '2011-01-01', x: 1, y: 2, z: 3, country: 'DE', title: 'first', lat:52.56, lon:13.40},
|
||||
{id: 1, date: '2011-02-02', x: 2, y: 4, z: 24, country: 'UK', title: 'second', lat:54.97, lon:-1.60},
|
||||
{id: 2, date: '2011-03-03', x: 3, y: 6, z: 9, country: 'US', title: 'third', lat:40.00, lon:-75.5},
|
||||
{id: 3, date: '2011-04-04', x: 4, y: 8, z: 6, country: 'UK', title: 'fourth', lat:57.27, lon:-6.20},
|
||||
{id: 4, date: '2011-05-04', x: 5, y: 10, z: 15, country: 'UK', title: 'fifth', lat:51.58, lon:0},
|
||||
{id: 5, date: '2011-06-02', x: 6, y: 12, z: 18, country: 'DE', title: 'sixth', lat:51.04, lon:7.9}
|
||||
{id: 0, date: '2011-01-01', x: 1, y: 2, z: 3, p: '4%', country: 'DE', title: 'first', lat:52.56, lon:13.40},
|
||||
{id: 1, date: '2011-02-02', x: 2, y: 4, z: 24, p: '14%',country: 'UK', title: 'second', lat:54.97, lon:-1.60},
|
||||
{id: 2, date: '2011-03-03', x: 3, y: 6, z: 9, p: '43%', country: 'US', title: 'third', lat:40.00, lon:-75.5},
|
||||
{id: 3, date: '2011-04-04', x: 4, y: 8, z: 6, p: '21%', country: 'UK', title: 'fourth', lat:57.27, lon:-6.20},
|
||||
{id: 4, date: '2011-05-04', x: 5, y: 10, z: 15, p: '29%', country: 'UK', title: 'fifth', lat:51.58, lon:0},
|
||||
{id: 5, date: '2011-06-02', x: 6, y: 12, z: 18, p: '87%', country: 'DE', title: 'sixth', lat:51.04, lon:7.9}
|
||||
];
|
||||
var dataset = new recline.Model.Dataset({records: documents, fields: fields});
|
||||
return dataset;
|
||||
|
||||
@ -55,6 +55,27 @@ test('dates in graph view', function () {
|
||||
view.remove();
|
||||
});
|
||||
|
||||
test('percentages in graph view', function () {
|
||||
var dataset = Fixture.getDataset();
|
||||
var view = new recline.View.Flot({
|
||||
model: dataset,
|
||||
state: {
|
||||
'graphType': 'lines',
|
||||
'group': 'country',
|
||||
'series': ['p']
|
||||
}
|
||||
});
|
||||
view.render();
|
||||
$('.fixtures').append(view.el);
|
||||
view.redraw();
|
||||
var graphData = view.plot.getData()[0].data;
|
||||
$.each(graphData, function(i, p){
|
||||
var percentage = p[1];
|
||||
equal($.isNumeric(percentage), true);
|
||||
});
|
||||
view.remove();
|
||||
});
|
||||
|
||||
test('FlotControls basics', function () {
|
||||
var dataset = Fixture.getDataset();
|
||||
var view = new recline.View.FlotControls({
|
||||
|
||||
@ -27,7 +27,7 @@ test('state', function () {
|
||||
var view = new recline.View.SlickGrid({
|
||||
model: dataset,
|
||||
state: {
|
||||
hiddenColumns:['x','lat','title'],
|
||||
hiddenColumns:['x','lat','title','p'],
|
||||
columnsOrder:['lon','id','z','date', 'y', 'country'],
|
||||
columnsWidth:[
|
||||
{column:'id',width: 250}
|
||||
@ -71,7 +71,7 @@ test('editable', function () {
|
||||
var view = new recline.View.SlickGrid({
|
||||
model: dataset,
|
||||
state: {
|
||||
hiddenColumns:['x','lat','title'],
|
||||
hiddenColumns:['x','lat','title','p'],
|
||||
columnsOrder:['lon','id','z','date', 'y', 'country'],
|
||||
columnsWidth:[
|
||||
{column:'id',width: 250}
|
||||
@ -108,7 +108,7 @@ test('delete-row' , function(){
|
||||
var view = new recline.View.SlickGrid({
|
||||
model: dataset,
|
||||
state: {
|
||||
hiddenColumns:['x','lat','title'],
|
||||
hiddenColumns:['x','lat','title','p'],
|
||||
columnsOrder:['lon','id','z','date', 'y', 'country'],
|
||||
columnsWidth:[
|
||||
{column:'id',width: 250}
|
||||
@ -154,7 +154,7 @@ test('delete-row-with-row-reorder-activated' , function(){
|
||||
var view = new recline.View.SlickGrid({
|
||||
model: dataset,
|
||||
state: {
|
||||
hiddenColumns:['x','lat','title'],
|
||||
hiddenColumns:['x','lat','title','p'],
|
||||
columnsOrder:['lon','id','z','date', 'y', 'country'],
|
||||
columnsWidth:[
|
||||
{column:'id',width: 250}
|
||||
@ -197,7 +197,7 @@ var dataset = Fixture.getDataset();
|
||||
var view = new recline.View.SlickGrid({
|
||||
model: dataset,
|
||||
state: {
|
||||
hiddenColumns:['x','lat','title'],
|
||||
hiddenColumns:['x','lat','title','p'],
|
||||
columnsOrder:['lon','id','z','date', 'y', 'country'],
|
||||
columnsWidth:[
|
||||
{column:'id',width: 250}
|
||||
@ -226,7 +226,7 @@ test('update', function() {
|
||||
var view = new recline.View.SlickGrid({
|
||||
model: dataset,
|
||||
state: {
|
||||
hiddenColumns:['x','lat','title'],
|
||||
hiddenColumns:['x','lat','title','p'],
|
||||
columnsOrder:['lon','id','z','date', 'y', 'country'],
|
||||
columnsWidth:[
|
||||
{column:'id',width: 250}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user