themustafaomar / jsvectormap

A lightweight JavaScript library for creating interactive maps and pretty data visualization.
https://jvm-docs.vercel.app
MIT License
369 stars 77 forks source link

fixed dataVisualization from displaying black region when there is 1 value #147

Closed alexboarotto closed 2 months ago

alexboarotto commented 2 months ago

In the visualize() method, colors for regions based on the provided values. However, when there's only one value, the color calculation is not being handled properly.

When you only have one value, the getValue() method is being called with the same value for this.min and this.max, resulting in a division by zero error. This leads to NaN making the color always black.

To address this issue we can check if the min and max value are the same and just return the _toColor as a default

themustafaomar commented 2 months ago

Thanks

I've applied additioanl fixes.