-
-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
197 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>Box Plot Chart</title> | ||
</head> | ||
<body> | ||
<div id="container" style="width: 75%;"> | ||
<canvas id="canvas"></canvas> | ||
</div> | ||
<script defer src="https://unpkg.com/es-module-shims"></script> | ||
<script type="importmap-shim"> | ||
{ | ||
"imports": { | ||
"chart.js": "https://unpkg.com/[email protected]/dist/Chart.esm.js", | ||
"chartjs-chart-geo": "../build/Chart.Geo.esm.js", | ||
"d3-geo": "https://unpkg.com/d3-geo?module", | ||
"d3-scale-chromatic": "https://unpkg.com/d3-scale-chromatic?module", | ||
"topojson-client": "https://unpkg.com/topojson-client?module" | ||
} | ||
} | ||
</script> | ||
<script type="module-shim"> | ||
import Chart from 'chart.js'; | ||
import { ChoroplethChart } from 'chartjs-chart-geo'; | ||
import {feature} from 'topojson-client'; | ||
|
||
fetch('https://unpkg.com/us-atlas/states-10m.json') | ||
.then((r) => r.json()) | ||
.then((us) => { | ||
const nation = feature(us, us.objects.nation).features[0]; | ||
const states = feature(us, us.objects.states).features; | ||
|
||
const chart = new ChoroplethChart(document.getElementById('canvas').getContext('2d'), { | ||
data: { | ||
labels: states.map((d) => d.properties.name), | ||
datasets: [ | ||
{ | ||
label: 'States', | ||
outline: nation, | ||
data: states.map((d) => ({ | ||
feature: d, | ||
value: Math.random() * 10, | ||
})), | ||
}, | ||
], | ||
}, | ||
options: { | ||
legend: { | ||
display: false, | ||
}, | ||
scales: { | ||
xy: { | ||
projection: 'albersUsa', | ||
}, | ||
color: { | ||
quantize: 5, | ||
legend: { | ||
position: 'bottom-right', | ||
align: 'right', | ||
}, | ||
}, | ||
}, | ||
}, | ||
}); | ||
}); | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
export * from '.'; | ||
|
||
import { Choropleth, BubbleMap } from './controllers'; | ||
import { ChoroplethController, BubbleMapController } from './controllers'; | ||
import { ColorLogarithmicScale, SizeLogarithmicScale } from './scales'; | ||
|
||
Choropleth.register(); | ||
BubbleMap.register(); | ||
ChoroplethController.register(); | ||
BubbleMapController.register(); | ||
|
||
ColorLogarithmicScale.register(); | ||
SizeLogarithmicScale.register(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import ChartNS from 'chart.js'; | ||
|
||
export const Chart = ChartNS; | ||
// export const plugins = ChartNS.plugins; | ||
export const controllers = ChartNS.controllers; | ||
export const defaults = ChartNS.defaults; | ||
// export const helpers = ChartNS.helpers; | ||
export const scaleService = ChartNS.scaleService; | ||
|
||
export const Scale = ChartNS.Scale; | ||
export const LinearScale = ChartNS.scaleService.getScaleConstructor('linear'); | ||
export const LogarithmicScale = ChartNS.scaleService.getScaleConstructor('logarithmic'); | ||
|
||
export const DatasetController = ChartNS.DatasetController; | ||
// export const BarController = controllers.bar; | ||
export const BubbleController = controllers.bubble; | ||
// export const HorizontalBarController = controllers.horizontalBar; | ||
// export const LineController = controllers.line; | ||
// export const PolarAreaController = controllers.polarArea; | ||
// export const ScatterController = controllers.scatter; | ||
|
||
export const Element = ChartNS.Element; | ||
// export const Rectangle = ChartNS.elements.Rectangle; | ||
export const Point = ChartNS.elements.Point; | ||
// export const Line = ChartNS.elements.Line; | ||
// export const Arc = ChartNS.elements.Arc; | ||
|
||
export const merge = ChartNS.helpers.merge; | ||
export const drawPoint = ChartNS.helpers.canvas.drawPoint; | ||
// export const resolve = ChartNS.helpers.options.resolve; | ||
// export const color = ChartNS.helpers.color; | ||
export const valueOrDefault = ChartNS.helpers.valueOrDefault; | ||
export const clipArea = ChartNS.helpers.canvas.clipArea; | ||
export const unclipArea = ChartNS.helpers.canvas.unclipArea; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export function patchControllerConfig(config, controller) { | ||
controller.register(); | ||
config.type = controller.id; | ||
return config; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.