Skip to content

Commit 87b6dbe

Browse files
committed
feat: modernize examples and resolve mixed chart visual regressions
1 parent 47befec commit 87b6dbe

8 files changed

Lines changed: 108 additions & 89 deletions

File tree

examples/amd.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
require.config({
55
paths: {
66
'angular': '../node_modules/angular/angular.min',
7-
'chart': '../node_modules/chart.js/dist/Chart.min',
8-
'angular-chart': '../src/angular-chart',
7+
'chart': '../node_modules/chart.js/dist/chart.umd',
8+
'angular-chart': '../dist/angular-chart',
99
},
1010
shim: {
1111
'angular': {

examples/app.ts

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
import type { ChartJsProviderInterface, ChartJsService, DirectiveScope } from '../src/angular-chart';
2-
import type { ActiveElement } from 'chart.js';
1+
// / <reference types="angular" />
2+
import type {ChartJsProviderInterface} from '../src/angular-chart';
3+
import type {ActiveElement} from 'chart.js';
34

45
interface ExampleScope extends angular.IScope {
56
labels: (string | string[])[];
@@ -36,6 +37,7 @@ interface NoDataScope extends ExampleScope {
3637
(() => {
3738
'use strict';
3839

40+
const angular = (window as any).angular as angular.IAngularStatic;
3941
const app = angular.module('examples', ['chart.js', 'ui.bootstrap']);
4042

4143
app.config(['ChartJsProvider', (ChartJsProvider: ChartJsProviderInterface) => {
@@ -62,7 +64,8 @@ interface NoDataScope extends ExampleScope {
6264
});
6365
ChartJsProvider.setOptions('bubble', {
6466
plugins: {
65-
tooltip: { enabled: false },
67+
legend: {display: false},
68+
tooltip: {enabled: false},
6669
},
6770
});
6871
}]);
@@ -104,7 +107,7 @@ interface NoDataScope extends ExampleScope {
104107
console.log('No point');
105108
}
106109
};
107-
$scope.datasetOverride = [{ yAxisID: 'y-axis-1' }, { yAxisID: 'y-axis-2' }];
110+
$scope.datasetOverride = [{yAxisID: 'y-axis-1'}, {yAxisID: 'y-axis-2'}];
108111

109112
$scope.options = {
110113
tension: 0.4,
@@ -127,7 +130,7 @@ interface NoDataScope extends ExampleScope {
127130
app.controller('BarCtrl', ['$scope', ($scope: ExampleScope) => {
128131
$scope.options = {
129132
plugins: {
130-
legend: { display: true },
133+
legend: {display: true},
131134
},
132135
};
133136
$scope.labels = ['2006', '2007', '2008', '2009', '2010', '2011', '2012'];
@@ -152,7 +155,7 @@ interface NoDataScope extends ExampleScope {
152155
$scope.data = [300, 500, 100];
153156
$scope.options = {
154157
plugins: {
155-
legend: { display: false },
158+
legend: {display: false},
156159
},
157160
};
158161
}]);
@@ -165,7 +168,7 @@ interface NoDataScope extends ExampleScope {
165168
$scope.data = [300, 500, 100, 40, 120];
166169
$scope.options = {
167170
plugins: {
168-
legend: { display: false },
171+
legend: {display: false},
169172
},
170173
};
171174
}]);
@@ -190,7 +193,7 @@ interface NoDataScope extends ExampleScope {
190193
];
191194
$scope.options = {
192195
plugins: {
193-
legend: { display: false },
196+
legend: {display: false},
194197
},
195198
};
196199

@@ -256,6 +259,7 @@ interface NoDataScope extends ExampleScope {
256259
label: 'Bar chart',
257260
borderWidth: 1,
258261
type: 'bar',
262+
backgroundColor: 'rgba(69, 183, 205, 0.2)',
259263
},
260264
{
261265
label: 'Line chart',
@@ -297,7 +301,7 @@ interface NoDataScope extends ExampleScope {
297301
];
298302
$scope.options = {
299303
plugins: {
300-
legend: { display: false },
304+
legend: {display: false},
301305
},
302306
};
303307
$scope.randomize = () => {
@@ -336,14 +340,15 @@ interface NoDataScope extends ExampleScope {
336340
$interval(createChart, 2000);
337341

338342
function createChart() {
339-
$scope.data = [];
343+
const data = [];
340344
for (let i = 0; i < 50; i++) {
341-
$scope.data.push([{
345+
data.push({
342346
x: randomScalingFactor(),
343347
y: randomScalingFactor(),
344348
r: randomRadius(),
345-
}]);
349+
});
346350
}
351+
$scope.data = [data];
347352
}
348353

349354
function randomScalingFactor() {

examples/bubble.js

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -10,39 +10,38 @@ angular.module('app', ['chart.js'])
1010

1111
$scope.options = {
1212
scales: {
13-
xAxes: [{
14-
display: false,
15-
ticks: {
16-
max: 125,
17-
min: -125,
18-
stepSize: 10,
19-
},
20-
}],
21-
yAxes: [{
13+
x: {
14+
type: 'linear',
15+
position: 'bottom',
16+
min: -125,
17+
max: 125,
18+
},
19+
y: {
20+
min: -125,
21+
max: 125,
22+
},
23+
},
24+
plugins: {
25+
legend: {
2226
display: false,
23-
ticks: {
24-
max: 125,
25-
min: -125,
26-
stepSize: 10,
27-
},
28-
}],
27+
},
2928
},
3029
};
3130

3231
createChart();
3332
$interval(createChart, 2000);
3433

3534
function createChart() {
36-
$scope.series = [];
37-
$scope.data = [];
35+
$scope.series = ['Series A'];
36+
const data = [];
3837
for (let i = 0; i < 50; i++) {
39-
$scope.series.push(`Series ${i}`);
40-
$scope.data.push([{
38+
data.push({
4139
x: randomScalingFactor(),
4240
y: randomScalingFactor(),
4341
r: randomRadius(),
44-
}]);
42+
});
4543
}
44+
$scope.data = [data];
4645
}
4746

4847
function randomScalingFactor() {

0 commit comments

Comments
 (0)