Skip to content

Commit

Permalink
Merge pull request #25 from aomra015/legendParent
Browse files Browse the repository at this point in the history
wrap canvas with a div if legend is true
  • Loading branch information
aomran committed Jun 7, 2015
2 parents 02904a1 + ea4402e commit cf65b4d
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
1 change: 1 addition & 0 deletions addon/components/ember-chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export default Ember.Component.extend({

if (this.get('legend')) {
var legend = chart.generateLegend();
this.$().wrap("<div class='chart-parent'></div>");
this.$().parent().append(legend);
}

Expand Down
4 changes: 2 additions & 2 deletions tests/dummy/app/templates/application.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

<div>
<h3>Pie Chart</h3>
{{ember-chart type='Pie' data=pieData width=200 height=200}}
{{ember-chart type='Pie' data=pieData width=200 height=200 legend=true}}
</div>

<div>
Expand Down Expand Up @@ -47,4 +47,4 @@
{{ember-chart type='polar area' data=polarAreaData width=400 height=400}}
</div>

{{outlet}}
{{outlet}}
13 changes: 13 additions & 0 deletions tests/unit/components/ember-chart-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,19 @@ test('it can be a pie chart', function(assert) {
assert.equal(chart.segments.length, 3);
});

test('it can be a pie chart with legend', function(assert) {
var component = this.subject({
type: 'Pie',
data: testData.get('pieData'),
legend: true
});

var chartParent = this.$().parent();

assert.ok(chartParent.hasClass('chart-parent'));
assert.ok(chartParent.find('.pie-legend').length);
});

test('it can be a line chart', function(assert) {
var component = this.subject({
type: 'Line',
Expand Down

0 comments on commit cf65b4d

Please sign in to comment.