Skip to content

Commit effcfe7

Browse files
authored
Merge pull request #102 from sgratzl/release/v3.7.0
Release v3.7.0
2 parents 8e7669a + c09fa63 commit effcfe7

19 files changed

+2773
-1516
lines changed

.eslintrc.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,14 @@
44
const pkg = require('./package.json');
55

66
module.exports = {
7-
plugins: ['@typescript-eslint', 'prettier'],
7+
plugins: [
8+
// '@typescript-eslint',
9+
'prettier',
10+
],
811
extends: [
9-
'airbnb-typescript',
12+
// 'airbnb-typescript',
1013
'react-app',
11-
'plugin:@typescript-eslint/recommended',
14+
// 'plugin:@typescript-eslint/recommended',
1215
'plugin:prettier/recommended',
1316
'prettier',
1417
],

.yarn/releases/yarn-3.1.0.cjs renamed to .yarn/releases/yarn-3.1.1.cjs

Lines changed: 150 additions & 150 deletions
Large diffs are not rendered by default.

.yarnrc.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ packageExtensions:
33
dependencies:
44
eslint-import-resolver-node: "*"
55

6-
yarnPath: .yarn/releases/yarn-3.1.0.cjs
6+
yarnPath: .yarn/releases/yarn-3.1.1.cjs

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,10 +181,10 @@ Variant A:
181181

182182
```js
183183
import { Chart } from 'chart.js';
184-
import { ChoroplethController } from 'chartjs-chart-geo';
184+
import { ChoroplethController, GeoFeature, ColorScale, ProjectionScale } from 'chartjs-chart-geo';
185185

186186
// register controller in chart.js and ensure the defaults are set
187-
ChoroplethController.register();
187+
Chart.register(ChoroplethController, GeoFeature, ColorScale, ProjectionScale);
188188

189189
const chart = new Chart(document.getElementById('canvas').getContext('2d'), {
190190
type: ChoroplethController.id,

package.json

Lines changed: 26 additions & 26 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.6.0",
4+
"version": "3.7.0",
55
"author": {
66
"name": "Samuel Gratzl",
77
"email": "sam@sgratzl.com",
@@ -36,7 +36,7 @@
3636
"src/**/*.ts"
3737
],
3838
"peerDependencies": {
39-
"chart.js": "^3.6.0"
39+
"chart.js": "^3.7.0"
4040
},
4141
"dependencies": {
4242
"@types/d3-geo": "^3.0.2",
@@ -49,43 +49,43 @@
4949
},
5050
"devDependencies": {
5151
"@rollup/plugin-commonjs": "^21.0.1",
52-
"@rollup/plugin-node-resolve": "^13.0.6",
53-
"@rollup/plugin-replace": "^3.0.0",
52+
"@rollup/plugin-node-resolve": "^13.1.3",
53+
"@rollup/plugin-replace": "^3.0.1",
5454
"@rollup/plugin-typescript": "^8.3.0",
55-
"@types/jest": "^27.0.2",
55+
"@types/jest": "^27.4.0",
5656
"@types/jest-image-snapshot": "^4.3.1",
57-
"@types/node": "^16.11.6",
57+
"@types/node": "^17.0.16",
5858
"@types/seedrandom": "^3.0.1",
59-
"@typescript-eslint/eslint-plugin": "^5.3.0",
60-
"@typescript-eslint/parser": "^5.3.0",
59+
"@typescript-eslint/eslint-plugin": "^5.11.0",
60+
"@typescript-eslint/parser": "^5.11.0",
6161
"@yarnpkg/pnpify": "^3.1.0",
6262
"@yarnpkg/sdks": "^2.5.0",
63-
"canvas": "^2.8.0",
63+
"canvas": "^2.9.0",
6464
"canvas-5-polyfill": "^0.1.5",
65-
"chart.js": "^3.6.0",
66-
"eslint": "^8.1.0",
67-
"eslint-config-airbnb-typescript": "^14.0.1",
65+
"chart.js": "^3.7.0",
66+
"eslint": "^8.8.0",
67+
"eslint-config-airbnb-typescript": "^16.1.0",
6868
"eslint-config-prettier": "^8.3.0",
69-
"eslint-config-react-app": "^6.0.0",
69+
"eslint-config-react-app": "^7.0.0",
7070
"eslint-plugin-flowtype": "^8.0.3",
71-
"eslint-plugin-import": "^2.25.2",
72-
"eslint-plugin-jsx-a11y": "^6.4.1",
71+
"eslint-plugin-import": "^2.25.4",
72+
"eslint-plugin-jsx-a11y": "^6.5.1",
7373
"eslint-plugin-prettier": "^4.0.0",
74-
"eslint-plugin-react": "^7.26.1",
75-
"eslint-plugin-react-hooks": "^4.2.0",
76-
"jest": "^27.3.1",
74+
"eslint-plugin-react": "^7.28.0",
75+
"eslint-plugin-react-hooks": "^4.3.0",
76+
"jest": "^27.5.1",
7777
"jest-image-snapshot": "^4.5.1",
78-
"prettier": "^2.4.1",
78+
"prettier": "^2.5.1",
7979
"rimraf": "^3.0.2",
80-
"rollup": "^2.59.0",
80+
"rollup": "^2.67.1",
8181
"rollup-plugin-cleanup": "^3.2.1",
82-
"rollup-plugin-dts": "^4.0.0",
82+
"rollup-plugin-dts": "^4.1.0",
8383
"rollup-plugin-terser": "^7.0.2",
8484
"seedrandom": "^3.0.5",
85-
"ts-jest": "^27.0.7",
85+
"ts-jest": "^27.1.3",
8686
"tslib": "^2.3.1",
87-
"typedoc": "^0.22.7",
88-
"typescript": "^4.4.4",
87+
"typedoc": "^0.22.11",
88+
"typescript": "^4.5.5",
8989
"us-atlas": "^3.0.0",
9090
"world-atlas": "^2.0.2"
9191
},
@@ -111,9 +111,9 @@
111111
"docs": "typedoc src/index.ts",
112112
"prepare": "yarn run build"
113113
},
114-
"packageManager": "yarn@3.1.0",
114+
"packageManager": "yarn@3.1.1",
115115
"dependenciesMeta": {
116-
"chart.js@3.6.0": {
116+
"chart.js@3.7.0": {
117117
"unplugged": true
118118
}
119119
}

samples/albers.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<!DOCTYPE html>
22
<html>
33
<head>
4-
<script src="https://unpkg.com/chart.js@3.6.0/dist/chart.js"></script>
4+
<script src="https://unpkg.com/chart.js@3.7.0/dist/chart.js"></script>
55
<script src="../build/index.umd.js"></script>
66
</head>
77

samples/albersCustom.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<!DOCTYPE html>
22
<html>
33
<head>
4-
<script src="https://unpkg.com/chart.js@3.6.0/dist/chart.js"></script>
4+
<script src="https://unpkg.com/chart.js@3.7.0/dist/chart.js"></script>
55
<script src="../build/index.umd.js"></script>
66
</head>
77

samples/albersLegend.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<!DOCTYPE html>
22
<html>
33
<head>
4-
<script src="https://unpkg.com/chart.js@3.6.0/dist/chart.js"></script>
4+
<script src="https://unpkg.com/chart.js@3.7.0/dist/chart.js"></script>
55
<script src="../build/index.umd.js"></script>
66
</head>
77

samples/albersLog.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<!DOCTYPE html>
22
<html>
33
<head>
4-
<script src="https://unpkg.com/chart.js@3.6.0/dist/chart.js"></script>
4+
<script src="https://unpkg.com/chart.js@3.7.0/dist/chart.js"></script>
55
<script src="../build/index.umd.js"></script>
66
</head>
77

samples/bubbleMap.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<!DOCTYPE html>
22
<html>
33
<head>
4-
<script src="https://unpkg.com/chart.js@3.6.0/dist/chart.js"></script>
4+
<script src="https://unpkg.com/chart.js@3.7.0/dist/chart.js"></script>
55
<script src="https://unpkg.com/chartjs-plugin-datalabels@next"></script>
66
<script src="../build/index.umd.js"></script>
77
<script src="https://unpkg.com/papaparse"></script>

samples/bubbleMapArea.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<!DOCTYPE html>
22
<html>
33
<head>
4-
<script src="https://unpkg.com/chart.js@3.6.0/dist/chart.js"></script>
4+
<script src="https://unpkg.com/chart.js@3.7.0/dist/chart.js"></script>
55
<!-- <script src="https://unpkg.com/chartjs-plugin-datalabels"></script> -->
66
<script src="../build/index.umd.js"></script>
77
<script src="https://unpkg.com/papaparse"></script>

samples/bubbleMapLog.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<!DOCTYPE html>
22
<html>
33
<head>
4-
<script src="https://unpkg.com/chart.js@3.6.0/dist/chart.js"></script>
4+
<script src="https://unpkg.com/chart.js@3.7.0/dist/chart.js"></script>
55
<!-- <script src="https://unpkg.com/chartjs-plugin-datalabels"></script> -->
66
<script src="../build/index.umd.js"></script>
77
<script src="https://unpkg.com/papaparse"></script>

samples/default_esm.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
<script type="importmap-shim">
1212
{
1313
"imports": {
14-
"chart.js": "https://unpkg.com/chart.js@3.6.0?module",
15-
"chart.js/helpers": "https://unpkg.com/chart.js@3.6.0/helpers/helpers.esm.js?module",
14+
"chart.js": "https://unpkg.com/chart.js@3.7.0?module",
15+
"chart.js/helpers": "https://unpkg.com/chart.js@3.7.0/helpers/helpers.esm.js?module",
1616
"chartjs-chart-geo": "../build/index.js",
1717
"d3-geo": "https://unpkg.com/d3-geo?module",
1818
"d3-scale-chromatic": "https://unpkg.com/d3-scale-chromatic?module",

samples/earth.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<!DOCTYPE html>
22
<html>
33
<head>
4-
<script src="https://unpkg.com/chart.js@3.6.0/dist/chart.js"></script>
4+
<script src="https://unpkg.com/chart.js@3.7.0/dist/chart.js"></script>
55
<script src="../build/index.umd.js"></script>
66
</head>
77

samples/earth_click.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<!DOCTYPE html>
22
<html>
33
<head>
4-
<script src="https://unpkg.com/chart.js@3.6.0/dist/chart.js"></script>
4+
<script src="https://unpkg.com/chart.js@3.7.0/dist/chart.js"></script>
55
<script src="../build/index.umd.js"></script>
66
</head>
77

samples/germany.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<!DOCTYPE html>
22
<html>
33
<head>
4-
<script src="https://unpkg.com/chart.js@3.6.0/dist/chart.js"></script>
4+
<script src="https://unpkg.com/chart.js@3.7.0/dist/chart.js"></script>
55
<script src="../build/index.umd.js"></script>
66
</head>
77

@@ -50,6 +50,7 @@
5050
scales: {
5151
xy: {
5252
projection: 'equalEarth',
53+
padding: 10,
5354
},
5455
},
5556
},

src/elements/GeoFeature.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ export class GeoFeature extends Element<IGeoFeatureProps, IGeoFeatureOptions> im
150150
}
151151
if (options.borderColor) {
152152
ctx.strokeStyle = options.borderColor;
153-
ctx.lineWidth = options.borderWidth;
153+
ctx.lineWidth = options.borderWidth as number;
154154
ctx.stroke();
155155
}
156156
}

src/scales/ProjectionScale.ts

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,19 @@ export interface IProjectionScaleOptions extends CoreScaleOptions {
6969
| 'transverseMercator'
7070
| 'naturalEarth1';
7171

72+
/**
73+
* extra scale factor applied to projection
74+
*/
7275
projectionScale: number;
76+
/**
77+
* extra offset applied after projection
78+
*/
7379
projectionOffset: [number, number];
80+
/**
81+
* padding applied during auto scaling of the map in pixels
82+
* i.e. the chart size is reduce by the padding before fitting the map
83+
*/
84+
padding: number | { top: number; left: number; right: number; bottom: number };
7485
}
7586

7687
export class ProjectionScale extends Scale<IProjectionScaleOptions> {
@@ -135,9 +146,14 @@ export class ProjectionScale extends Scale<IProjectionScaleOptions> {
135146
if (!bb) {
136147
return false;
137148
}
149+
const padding = this.options.padding;
150+
const paddingTop = typeof padding === 'number' ? padding : padding.top;
151+
const paddingLeft = typeof padding === 'number' ? padding : padding.left;
152+
const paddingBottom = typeof padding === 'number' ? padding : padding.bottom;
153+
const paddingRight = typeof padding === 'number' ? padding : padding.right;
138154

139-
const chartWidth = area.right - area.left;
140-
const chartHeight = area.bottom - area.top;
155+
const chartWidth = area.right - area.left - paddingLeft - paddingRight;
156+
const chartHeight = area.bottom - area.top - paddingTop - paddingBottom;
141157

142158
const bak = this.oldChartBounds;
143159
this.oldChartBounds = {
@@ -149,8 +165,8 @@ export class ProjectionScale extends Scale<IProjectionScaleOptions> {
149165
const viewWidth = bb.width * scale;
150166
const viewHeight = bb.height * scale;
151167

152-
const x = (chartWidth - viewWidth) * 0.5 + area.left;
153-
const y = (chartHeight - viewHeight) * 0.5 + area.top;
168+
const x = (chartWidth - viewWidth) * 0.5 + area.left + paddingLeft;
169+
const y = (chartHeight - viewHeight) * 0.5 + area.top + paddingTop;
154170

155171
// this.mapScale = scale;
156172
// this.mapTranslate = {x, y};
@@ -172,6 +188,7 @@ export class ProjectionScale extends Scale<IProjectionScaleOptions> {
172188
projection: 'albersUsa',
173189
projectionScale: 1,
174190
projectionOffset: [0, 0],
191+
padding: 0,
175192
};
176193

177194
static readonly descriptors = /* #__PURE__ */ {

0 commit comments

Comments
 (0)