c3-angular-directive
c3-angular-directive copied to clipboard
Commas in data cause data to become misinterpreted
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 useString.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
Any news regarding this feature? It really is a big issue because there are data in which you just cannot replace the comma with some other symbol.
No not really, don't have the issue myself, though I do understand your problem. But it is not top of my priority list. Open for pull requests though