Browse Source

Fix class suffix - #717

pull/729/head
Masayuki Tanaka 10 years ago
parent
commit
73cb2b97b3
  1. 2
      c3.js
  2. 2
      c3.min.js
  3. 6
      spec/class-spec.js
  4. 2
      src/class.js

2
c3.js

@ -5523,7 +5523,7 @@
return CLASS.chartArc + this.classTarget(d.data.id); return CLASS.chartArc + this.classTarget(d.data.id);
}; };
c3_chart_internal_fn.getTargetSelectorSuffix = function (targetId) { c3_chart_internal_fn.getTargetSelectorSuffix = function (targetId) {
return targetId || targetId === 0 ? ('-' + targetId).replace(/[\s!@#$%^&*()_+,.<>'":;\[\]]/g, '-') : ''; return targetId || targetId === 0 ? ('-' + targetId).replace(/[\s?!@#$%^&*()_+,.<>'":;\[\]/|]/g, '-') : '';
}; };
c3_chart_internal_fn.selectorTarget = function (id, prefix) { c3_chart_internal_fn.selectorTarget = function (id, prefix) {
return (prefix || '') + '.' + CLASS.target + this.getTargetSelectorSuffix(id); return (prefix || '') + '.' + CLASS.target + this.getTargetSelectorSuffix(id);

2
c3.min.js vendored

File diff suppressed because one or more lines are too long

6
spec/class-spec.js

@ -11,7 +11,7 @@ describe('c3 chart class', function () {
var args = { var args = {
data: { data: {
columns: [ columns: [
['data1 [0]', 30, 200, 100, 400, 150, 250], ['data1', 30, 200, 100, 400, 150, 250],
['data2 prefix', 50, 20, 10, 40, 15, 25], ['data2 prefix', 50, 20, 10, 40, 15, 25],
['data3 мужчины', 150, 120, 110, 140, 115, 125] ['data3 мужчины', 150, 120, 110, 140, 115, 125]
] ]
@ -47,8 +47,8 @@ describe('c3 chart class', function () {
}); });
it('should replace special charactors to "-"', function () { it('should replace special charactors to "-"', function () {
var input = 'data1 !@#$%^&*()_+,.<>"\':;[]', var input = 'data1 !@#$%^&*()_+,.<>"\':;[]/|?',
expected = '-data1-----------------------', expected = '-data1--------------------------',
suffix = chart.internal.getTargetSelectorSuffix(input); suffix = chart.internal.getTargetSelectorSuffix(input);
expect(suffix).toBe(expected); expect(suffix).toBe(expected);
}); });

2
src/class.js

@ -155,7 +155,7 @@ c3_chart_internal_fn.classChartArc = function (d) {
return CLASS.chartArc + this.classTarget(d.data.id); return CLASS.chartArc + this.classTarget(d.data.id);
}; };
c3_chart_internal_fn.getTargetSelectorSuffix = function (targetId) { c3_chart_internal_fn.getTargetSelectorSuffix = function (targetId) {
return targetId || targetId === 0 ? ('-' + targetId).replace(/[\s!@#$%^&*()_+,.<>'":;\[\]]/g, '-') : ''; return targetId || targetId === 0 ? ('-' + targetId).replace(/[\s?!@#$%^&*()_+,.<>'":;\[\]/|]/g, '-') : '';
}; };
c3_chart_internal_fn.selectorTarget = function (id, prefix) { c3_chart_internal_fn.selectorTarget = function (id, prefix) {
return (prefix || '') + '.' + CLASS.target + this.getTargetSelectorSuffix(id); return (prefix || '') + '.' + CLASS.target + this.getTargetSelectorSuffix(id);

Loading…
Cancel
Save