Giter Club home page Giter Club logo

Comments (3)

sgratzl avatar sgratzl commented on June 3, 2024 1

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

from chartjs-chart-geo.

nemesisKO avatar nemesisKO commented on June 3, 2024

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

from chartjs-chart-geo.

nemesisKO avatar nemesisKO commented on June 3, 2024

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' } } } })

from chartjs-chart-geo.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.