Skip to content

Commit 97665d4

Browse files
authored
Merge pull request #121 from sgratzl/release/v3.8.1
Release v3.8.1
2 parents 14e2b23 + f8b675a commit 97665d4

File tree

4 files changed

+160
-83
lines changed

4 files changed

+160
-83
lines changed

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "chartjs-chart-geo",
33
"description": "Chart.js module for charting maps",
4-
"version": "3.8.0",
4+
"version": "3.8.1",
55
"author": {
66
"name": "Samuel Gratzl",
77
"email": "sam@sgratzl.com",
@@ -55,10 +55,10 @@
5555
"@rollup/plugin-typescript": "^8.3.3",
5656
"@types/jest": "^28.1.4",
5757
"@types/jest-image-snapshot": "^5.1.0",
58-
"@types/node": "^18.0.1",
58+
"@types/node": "^18.0.3",
5959
"@types/seedrandom": "^3.0.2",
60-
"@typescript-eslint/eslint-plugin": "^5.30.4",
61-
"@typescript-eslint/parser": "^5.30.4",
60+
"@typescript-eslint/eslint-plugin": "^5.30.5",
61+
"@typescript-eslint/parser": "^5.30.5",
6262
"@yarnpkg/pnpify": "^3.1.3",
6363
"@yarnpkg/sdks": "^2.6.2",
6464
"canvas": "^2.9.3",

samples/changing.html

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<script src="https://unpkg.com/chart.js@3.8.0/dist/chart.js"></script>
5+
<script src="../build/index.umd.js"></script>
6+
</head>
7+
8+
<body>
9+
<div style="width: 75%">
10+
<canvas id="canvas" style="border: 1px solid black"></canvas>
11+
</div>
12+
<script>
13+
fetch('https://unpkg.com/us-atlas/states-10m.json')
14+
.then((r) => r.json())
15+
.then((us) => {
16+
const nation = ChartGeo.topojson.feature(us, us.objects.nation).features[0];
17+
const states = ChartGeo.topojson.feature(us, us.objects.states).features;
18+
19+
const chart = new Chart(document.getElementById('canvas').getContext('2d'), {
20+
type: 'choropleth',
21+
data: {
22+
labels: states.map((d) => d.properties.name),
23+
datasets: [
24+
{
25+
label: 'States',
26+
outline: nation,
27+
data: states.map((d) => ({
28+
feature: d,
29+
value: Math.random() * 11,
30+
})),
31+
},
32+
],
33+
},
34+
options: {
35+
plugins: {
36+
legend: {
37+
display: false,
38+
},
39+
},
40+
scales: {
41+
xy: {
42+
projection: 'albersUsa',
43+
},
44+
color: {
45+
quantize: 5,
46+
legend: {
47+
position: 'bottom-right',
48+
align: 'right',
49+
},
50+
},
51+
},
52+
},
53+
});
54+
55+
setTimeout(() => {
56+
chart.options.scales.xy = {
57+
projection: 'equalEarth',
58+
projectionOffset: [100, 0],
59+
};
60+
chart.update();
61+
62+
setTimeout(() => {
63+
chart.options.scales.xy = {
64+
projection: 'albersUsa',
65+
projectionOffset: [-100, 0],
66+
};
67+
chart.update();
68+
}, 1000);
69+
}, 1000);
70+
});
71+
</script>
72+
</body>
73+
</html>

src/scales/ProjectionScale.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,9 @@ export class ProjectionScale extends Scale<IProjectionScaleOptions> {
116116
this.projection = (lookup[options.projection] || lookup.albersUsa)();
117117
}
118118
this.geoPath.projection(this.projection);
119+
120+
this.outlineBounds = null;
121+
this.oldChartBounds = null;
119122
}
120123

121124
computeBounds(outline: ExtendedFeature): void;
@@ -141,6 +144,7 @@ export class ProjectionScale extends Scale<IProjectionScaleOptions> {
141144

142145
updateBounds(): boolean {
143146
const area = this.chart.chartArea;
147+
144148
const bb = this.outlineBounds;
145149

146150
if (!bb) {

0 commit comments

Comments
 (0)