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

Custom _getNormalizedValue for option interpolate #251

Closed dieunq1001 closed 1 week ago

dieunq1001 commented 1 month ago

I'm having the following question...

I noticed that Interpolate will automatically normalize my value, which I do not want to. Is there anyway to custom my own _getNormalizedValue in interpolate or to not use it at all? Much appreciated.

sgratzl commented 1 month ago

internally a color scale just a fancy way to get a background color: https://github.com/sgratzl/chartjs-chart-geo/blob/9aacf4a1f9910b51e908d18e3d8459cc414d0950/src/controllers/ChoroplethController.ts#L138.

so you can just provide a custom backgroundColor and have access to all values.

dieunq1001 commented 4 weeks ago

I have tried this method to custom backgrounds color for my dataset. However, I can not find out a way to custom ColorScale to match the background colors value. Is there a callback function like Legend to custom ColorScale ?

sgratzl commented 1 week ago

there isn't a way since the the scale interface used to normalize and generate the color is limited to giving only a numeric value