Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error in vite #177

Closed
nemesisKO opened this issue May 18, 2023 · 3 comments
Closed

error in vite #177

nemesisKO opened this issue May 18, 2023 · 3 comments
Labels
bug Something isn't working

Comments

@nemesisKO
Copy link

The requested module '/node_modules/.vite/deps/chartjs-chart-geo.js?v=fe996f1c' does not provide an export named 'default'

any idea how to fix it?

@nemesisKO nemesisKO added the bug Something isn't working label May 18, 2023
@sgratzl
Copy link
Owner

sgratzl commented May 19, 2023

yes there is no default export:

https://github.com/sgratzl/chartjs-chart-geo/blob/main/src/index.ts

not sure how you import the library

@nemesisKO
Copy link
Author

nemesisKO commented May 21, 2023

i imported just like documentation
import { Chart , registerables} from 'chart.js'; import { ChoroplethController, GeoFeature, ColorScale, ProjectionScale } from 'chartjs-chart-geo'; Chart.register(ChoroplethController, GeoFeature, ColorScale, ProjectionScale);

im dont know how to use map. the documentation said
fetch('https://unpkg.com/world-atlas/countries-50m.json').then((r) => r.json()).then((data) => { const countries = ChartGeo.topojson.feature(data, data.objects.countries).features;

but where is ChartGeo. can you please show me a full example with using npm imports way. the codepen examples doesnt suite my project

@nemesisKO
Copy link
Author

i should have import topojson as wall to implement map. the complete code is below

import map from 'world-atlas/countries-50m.json';
import { topojson, ChoroplethController, GeoFeature, ColorScale, ProjectionScale } from 'chartjs-chart-geo';
Chart.register(ChoroplethController, GeoFeature, ColorScale, ProjectionScale);
const countries = topojson.feature(map, map.objects.countries).features;
const chart = new Chart(document.getElementById("myChart").getContext("2d"), {
type: 'choropleth',
data: {
labels: countries.map((d) => d.properties.name),
datasets: [{
label: 'Countries',
data:countries.map((d) => ({feature: d, value: d.value}))
}]
},
options: {
showOutline: true,
showGraticule: false,
plugins: {
legend: {
display: false
},
},
scales: {
projection: { axis: 'x', projection: 'equirectangular' } } } })

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants