Skip to content

Commit

Permalink
Added support for Discrete Bar Chart, Pie Chart, and improved all oth…
Browse files Browse the repository at this point in the history
…er charts and root chart class.
  • Loading branch information
Glavin001 committed Apr 13, 2014
1 parent df2a512 commit 5da1a9b
Show file tree
Hide file tree
Showing 17 changed files with 509 additions and 133 deletions.
121 changes: 119 additions & 2 deletions app/scripts/controllers/index_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ EmberNvd3.IndexController = Ember.ArrayController.extend({
for (i = 0; i < 5; i++) bump(a);
return a.map(stream_index);
});
}
}
function testData() {
return stream_layers(3,128,.1).map(function(data, i) {
return {
Expand All @@ -60,8 +60,125 @@ EmberNvd3.IndexController = Ember.ArrayController.extend({
};
});
}
self.set('lineData', testData());
self.set('lineChartData', testData());



function sinAndCos() {
var sin = [],
cos = [];

for (var i = 0; i < 100; i++) {
sin.push({x: i, y: Math.sin(i/10)});
cos.push({x: i, y: .5 * Math.cos(i/10)});
}

return [
{
values: sin,
key: "Sine Wave",
color: "#ff7f0e"
},
{
values: cos,
key: "Cosine Wave",
color: "#2ca02c"
}
];
}
function sinData() {
var sin = [];

for (var i = 0; i < 100; i++) {
sin.push({x: i, y: Math.sin(i/10)});
}

return [
{
values: sin,
key: "Sine Wave",
color: "#ff7f0e"
}
];
}
self.set('historicalBarChartData', sinData());


var historicalBarChart = [
{
key: "Cumulative Return",
values: [
{
"label" : "A" ,
"value" : 29.765957771107
} ,
{
"label" : "B" ,
"value" : 0
} ,
{
"label" : "C" ,
"value" : 32.807804682612
} ,
{
"label" : "D" ,
"value" : 196.45946739256
} ,
{
"label" : "E" ,
"value" : 0.19434030906893
} ,
{
"label" : "F" ,
"value" : 98.079782601442
} ,
{
"label" : "G" ,
"value" : 13.925743130903
} ,
{
"label" : "H" ,
"value" : 5.1387322875705
}
]
}
];
self.set('discreteBarChartData', historicalBarChart);



var testdata = [
{
key: "One",
y: 5
},
{
key: "Two",
y: 2
},
{
key: "Three",
y: 9
},
{
key: "Four",
y: 7
},
{
key: "Five",
y: 4
},
{
key: "Six",
y: 3
},
{
key: "Seven",
y: .5
}
];
self.set('pieChartData', testdata);

},
refresh: function() {
this.send('genData');
Expand Down
11 changes: 10 additions & 1 deletion app/templates/index.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,15 @@
{{nvd3-sparkline-plus data=sparklinePlusData}}

<h2>Line Chart</h2>
{{nvd3-line-with-focus-chart data=lineData}}
{{nvd3-line-with-focus-chart data=lineChartData}}

<h2>Historical Bar Chart</h2>
{{nvd3-historical-bar-chart data=historicalBarChartData}}

<h2>Discrete Bar Chart</h2>
{{nvd3-discrete-bar-chart data=discreteBarChartData}}

<h2>Pie Chart</h2>
{{nvd3-pie-chart data=pieChartData}}

</div>
11 changes: 7 additions & 4 deletions bower.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
{
"name": "ember-nvd3",
"version": "0.0.0",
"version": "0.1.0",
"dependencies": {
"ember": "^1.3.2",
"handlebars": "^1.2.1",
"ember-data": "^1.0.0-beta.5",
"bootstrap-sass": "~3.0.0",
"bootstrap-sass": "^3.0.0",
"d3": "~3.3.13",
"jquery": "~2.1.0"
"jquery": "^2.1.0"
},
"devDependencies": {
"ember-mocha-adapter": "0.1.2"
}
},
"main": [
"build/ember-nvd3.js"
]
}
Loading

0 comments on commit 5da1a9b

Please sign in to comment.