jettro / jettro/c3-angular-directive

Commas in data cause data to become misinterpreted

Open
#161 2 comments 0 reactions 0 assignees View on GitHub
help wanted
Dominant language
JavaScript
Stars
201
Forks
96
PR merge metrics
No merged PRs in 30d

Description

Hi there,

There's an issue when you have/need a comma in any element in the data you'd like to pass to C3, that data series will be misinterpreted and the display will be incorrect.

The data array is reduced to a string with comma-separated elements when it's passed to the angular directive, and later there is logic to use`String.split(',')` to recreate the array for use in the C3 config object.

Example:
Notice the original data set begins with 2 elements and ends up with 4.
`["a, b", "x, y"]` -> `"a, b,x, y".split(',')` -> `["a", " b", "x", " y"]`

Does anyone have any ideas on how to resolve this? Using an html entity number to represent the comma doesn't work because at the bottom of the stack, C3 or D3 is escaping html characters.

I thought about having an escape character or something before the comma or around the comma, and instead of doing `String.split(',')`, we could do `["a%,% b,x%,% y"].split(/(?!%),(?!%)/)` and then we'd have to `.map(d => d.replace('%,%', ','))` to make it appear as intended.

http://stackoverflow.com/questions/42691215/how-to-make-c3-ignore-comma-in-column-values/42777308?noredirect=1#comment72733784_42777308

Area in code that this specific instance is happening: https://github.com/jettro/c3-angular-directive/blob/master/src/column-directive.js#L48

But there are other places where `/\.split\(['"],["']\)/` is being used

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.