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

Data module removing 0's in fips codes #16920

Closed
kai2468 opened this issue Jan 25, 2022 · 2 comments · Fixed by #20125
Closed

Data module removing 0's in fips codes #16920

kai2468 opened this issue Jan 25, 2022 · 2 comments · Fixed by #20125

Comments

@kai2468
Copy link
Contributor

kai2468 commented Jan 25, 2022

Expected behaviour

The data module does not remove the first 0 in the fips code and the map renders correctly

Actual behaviour

The data module removes the first 0 in the fips code and the map does not render any of its points.

An example of a fips code in the Alabama map: 01007

The data module seems to be removing the first 0 in the codes, and so Highmaps cant find the right code to link to.

If you log mapKey and mapMap in the line I've linked below, you'll see that the codes do not match. I assume the data module is doing some custom parsing before it gets to this point and the 0 is getting removed because of it.

https://github.com/highcharts/highcharts/blob/master/ts/Series/Map/MapSeries.ts#L1057

Live demo with steps to reproduce

https://jsfiddle.net/vf2yeL5g/

Product version

Latest

@highsoft-bot highsoft-bot added this to To do in Development-Flow Jan 25, 2022
@KacperMadej
Copy link

Hi @kai2468

Thank you for reporting the problem.

Internal note / more details:
Data module has the source of the problem - it is not a Maps specific issue.
A solution would be to have an option to indicate the type of each column in CSV. In code there is a trace of such option - columnTypes is the name. It is not documented and should work when checking the raw code. However, when debugging there is a part of guessed parsing of CSV before that option is even checked.

if (!isNaN(parseFloat(token)) && isFinite(token as any)) {
token = parseFloat(token) as any;
pushType('number');

So basically, if it is parsable it will be parsed, so there is no API option to prevent this.

A fix for the bug could be to add columnTypes as a API option (we already have some code in place, a test, and a demo using it).

PoC (with modified code marked with ------- comments): https://jsfiddle.net/BlackLabel/Ljxhgve4/

@kai2468
Copy link
Contributor Author

kai2468 commented Nov 7, 2023

Hi, any news on this one?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

Successfully merging a pull request may close this issue.

6 participants