|
|
|
import CLASS from './class';
|
|
|
|
import { c3_chart_internal_fn } from './core';
|
|
|
|
|
|
|
|
|
|
|
|
c3_chart_internal_fn.generateTargetClass = function (targetId) {
|
|
|
|
return targetId || targetId === 0 ? ('-' + targetId).replace(/\s/g, '-') : '';
|
|
|
|
};
|
|
|
|
c3_chart_internal_fn.generateClass = function (prefix, targetId) {
|
|
|
|
return " " + prefix + " " + prefix + this.generateTargetClass(targetId);
|
|
|
|
};
|
|
|
|
c3_chart_internal_fn.classText = function (d) {
|
|
|
|
return this.generateClass(CLASS.text, d.index);
|
|
|
|
};
|
|
|
|
c3_chart_internal_fn.classTexts = function (d) {
|
|
|
|
return this.generateClass(CLASS.texts, d.id);
|
|
|
|
};
|
|
|
|
c3_chart_internal_fn.classShape = function (d) {
|
|
|
|
return this.generateClass(CLASS.shape, d.index);
|
|
|
|
};
|
|
|
|
c3_chart_internal_fn.classShapes = function (d) {
|
|
|
|
return this.generateClass(CLASS.shapes, d.id);
|
|
|
|
};
|
|
|
|
c3_chart_internal_fn.classLine = function (d) {
|
|
|
|
return this.classShape(d) + this.generateClass(CLASS.line, d.id);
|
|
|
|
};
|
|
|
|
c3_chart_internal_fn.classLines = function (d) {
|
|
|
|
return this.classShapes(d) + this.generateClass(CLASS.lines, d.id);
|
|
|
|
};
|
|
|
|
c3_chart_internal_fn.classCircle = function (d) {
|
|
|
|
return this.classShape(d) + this.generateClass(CLASS.circle, d.index);
|
|
|
|
};
|
|
|
|
c3_chart_internal_fn.classCircles = function (d) {
|
|
|
|
return this.classShapes(d) + this.generateClass(CLASS.circles, d.id);
|
|
|
|
};
|
|
|
|
c3_chart_internal_fn.classBar = function (d) {
|
|
|
|
return this.classShape(d) + this.generateClass(CLASS.bar, d.index);
|
|
|
|
};
|
|
|
|
c3_chart_internal_fn.classBars = function (d) {
|
|
|
|
return this.classShapes(d) + this.generateClass(CLASS.bars, d.id);
|
|
|
|
};
|
|
|
|
c3_chart_internal_fn.classArc = function (d) {
|
|
|
|
return this.classShape(d.data) + this.generateClass(CLASS.arc, d.data.id);
|
|
|
|
};
|
|
|
|
c3_chart_internal_fn.classArcs = function (d) {
|
|
|
|
return this.classShapes(d.data) + this.generateClass(CLASS.arcs, d.data.id);
|
|
|
|
};
|
|
|
|
c3_chart_internal_fn.classArea = function (d) {
|
|
|
|
return this.classShape(d) + this.generateClass(CLASS.area, d.id);
|
|
|
|
};
|
|
|
|
c3_chart_internal_fn.classAreas = function (d) {
|
|
|
|
return this.classShapes(d) + this.generateClass(CLASS.areas, d.id);
|
|
|
|
};
|
|
|
|
c3_chart_internal_fn.classRegion = function (d, i) {
|
|
|
|
return this.generateClass(CLASS.region, i) + ' ' + ('class' in d ? d['class'] : '');
|
|
|
|
};
|
|
|
|
c3_chart_internal_fn.classEvent = function (d) {
|
|
|
|
return this.generateClass(CLASS.eventRect, d.index);
|
|
|
|
};
|
|
|
|
c3_chart_internal_fn.classTarget = function (id) {
|
|
|
|
var $$ = this;
|
|
|
|
var additionalClassSuffix = $$.config.data_classes[id], additionalClass = '';
|
|
|
|
if (additionalClassSuffix) {
|
|
|
|
additionalClass = ' ' + CLASS.target + '-' + additionalClassSuffix;
|
|
|
|
}
|
|
|
|
return $$.generateClass(CLASS.target, id) + additionalClass;
|
|
|
|
};
|
|
|
|
c3_chart_internal_fn.classFocus = function (d) {
|
|
|
|
return this.classFocused(d) + this.classDefocused(d);
|
|
|
|
};
|
|
|
|
c3_chart_internal_fn.classFocused = function (d) {
|
|
|
|
return ' ' + (this.focusedTargetIds.indexOf(d.id) >= 0 ? CLASS.focused : '');
|
|
|
|
};
|
|
|
|
c3_chart_internal_fn.classDefocused = function (d) {
|
|
|
|
return ' ' + (this.defocusedTargetIds.indexOf(d.id) >= 0 ? CLASS.defocused : '');
|
|
|
|
};
|
|
|
|
c3_chart_internal_fn.classChartText = function (d) {
|
|
|
|
return CLASS.chartText + this.classTarget(d.id);
|
|
|
|
};
|
|
|
|
c3_chart_internal_fn.classChartLine = function (d) {
|
|
|
|
return CLASS.chartLine + this.classTarget(d.id);
|
|
|
|
};
|
|
|
|
c3_chart_internal_fn.classChartBar = function (d) {
|
|
|
|
return CLASS.chartBar + this.classTarget(d.id);
|
|
|
|
};
|
|
|
|
c3_chart_internal_fn.classChartArc = function (d) {
|
|
|
|
return CLASS.chartArc + this.classTarget(d.data.id);
|
|
|
|
};
|
|
|
|
c3_chart_internal_fn.getTargetSelectorSuffix = function (targetId) {
|
|
|
|
return this.generateTargetClass(targetId)
|
|
|
|
.replace(/([?!@#$%^&*()_=+,.<>'":;\[\]\/|~`{}\\])/g, '\\$1');
|
|
|
|
};
|
|
|
|
c3_chart_internal_fn.selectorTarget = function (id, prefix) {
|
|
|
|
return (prefix || '') + '.' + CLASS.target + this.getTargetSelectorSuffix(id);
|
|
|
|
};
|
|
|
|
c3_chart_internal_fn.selectorTargets = function (ids, prefix) {
|
|
|
|
var $$ = this;
|
|
|
|
ids = ids || [];
|
|
|
|
return ids.length ? ids.map(function (id) { return $$.selectorTarget(id, prefix); }) : null;
|
|
|
|
};
|
|
|
|
c3_chart_internal_fn.selectorLegend = function (id) {
|
|
|
|
return '.' + CLASS.legendItem + this.getTargetSelectorSuffix(id);
|
|
|
|
};
|
|
|
|
c3_chart_internal_fn.selectorLegends = function (ids) {
|
|
|
|
var $$ = this;
|
|
|
|
return ids && ids.length ? ids.map(function (id) { return $$.selectorLegend(id); }) : null;
|
|
|
|
};
|