sgratzl / chartjs-chart-geo

Chart.js Choropleth and Bubble Maps
https://www.sgratzl.com/chartjs-chart-geo/
MIT License
347 stars 36 forks source link

options.scales.Projection: "orthographic" - How could I approach rotating the world view? #168

Closed Josh-Ring-SD closed 1 year ago

Josh-Ring-SD commented 1 year ago

options.scales.Projection: "orthographic" - is it possible to rotate the world?

Currently I can see in the code and examples for options.scales these options: projectionScale and projectionOffset

When using options.scales.Projection: "orthographic" I was interested to show a view of Asia, which would require rotating the view or the world to that point.

Europe

image

Asia: (quite distorted, ideally would want to rotate the orthographic projection)

image

This is a related question with D3: https://stackoverflow.com/questions/31693580/update-map-rotation-with-angles-with-orthographic-projection (since I can see projections are from D3 here: https://github.com/sgratzl/chartjs-chart-geo/blob/97665d4bc8f12c2e1fc1e3ca251b11914f03f1c4/src/scales/ProjectionScale.ts)

How might I approach this?

sgratzl commented 1 year ago

the projection option not only allows to set one of the predefined subset but you can provide a d3 projection object directly:

https://github.com/sgratzl/chartjs-chart-geo/blob/4036bdf49111544aa7091e22f0c9f059dab4a0a8/src/scales/ProjectionScale.ts#L54-L70

so you can create your d3 projection manually and provide this object to the chart.js plugin

Josh-Ring-SD commented 1 year ago

Aha, fantastic! Thanks @sgratzl