Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ Allowed values - `'pie', 'bar', 'line', 'point', 'area'`

```js
var config = {
title: '', // chart title
title: '', // chart title. If this is false, no title element will be created.
tooltips: true,
labels: false, // labels on data points
// exposed events
Expand Down
2 changes: 1 addition & 1 deletion src/templates/left.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div class="angular-charts-template">
<div class='ac-title'>{{acConfig.title}}</div>
<div class='ac-title' ng-if="acConfig.title !== false">{{acConfig.title}}</div>
<div class='ac-legend' ng-show='{{acConfig.legend.display}}'>
<table>
<tr ng-repeat="l in legends">
Expand Down
2 changes: 1 addition & 1 deletion src/templates/right.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div class="angular-charts-template">
<div class='ac-title'>{{acConfig.title}}</div>
<div class='ac-title' ng-if="acConfig.title !== false">{{acConfig.title}}</div>
<div class='ac-chart'>
</div>
<div class='ac-legend' ng-show='{{acConfig.legend.display}}'>
Expand Down
34 changes: 29 additions & 5 deletions test/angular-charts.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ describe('angularCharts', function() {
expect(compileChart).toThrow()
})

it('should throw width/height error', function() {
it('should not throw width/height error if the chart has a width/height', function() {
angular.element(document.body).append('<style type="text/css">#chart { width:150px; height: 300px}</style>')
expect(compileChart).not.toThrow()
})
Expand All @@ -89,10 +89,6 @@ describe('angularCharts', function() {
$chart_childrens = angular.element($chart).children()
})

it('should have the right DOM title', function() {
expect($chart.querySelector('.ac-title').innerText).toEqual('Not Products')
})

it('should have the right elements in the legend', function() {

var $legendItems = $chart.querySelector('.ac-legend tbody').children
Expand Down Expand Up @@ -209,4 +205,32 @@ describe('angularCharts', function() {

})

describe('title', function() {
beforeEach(function() {
angular.element(document.body).append('<style type="text/css">#chart { width:150px; height: 300px}</style>');
$scope.chartType = 'area';
});

it('should set the title in the title element', function() {
$scope.config.title = 'My Title';

compileChart();
$scope.$digest();

$chart = document.getElementById('chart')
expect($chart.querySelectorAll('.ac-title').length).toBe(1);
expect($chart.querySelector('.ac-title').innerText).toEqual('My Title')
});

it('should not have a title element if the title is false', function() {
$scope.config.title = false;

compileChart();
$scope.$digest();

$chart = document.getElementById('chart');
expect($chart.querySelectorAll('.ac-title').length).toBe(0);
});

});
})