jettro/c3-angular-directive

Commas in data cause data to become misinterpreted

开放

#161 创建于 2017年3月17日

 (2 条评论) (0 个反应) (0 位负责人)JavaScript (96 个派生)github user discovery
help wanted

仓库指标

星标
 (201 个星标)
PR 合并指标
 (30 天内没有已合并 PR)

描述

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

贡献者指南