mirror of https://github.com/masayuki0812/c3.git
Browse Source
* chore: define run scripts, reduce grunt usage * refactor(rollup): switch to rollup * chore: fix node.js version on ci envpull/1595/merge
Yoshiya Hinosawa
8 years ago
committed by
Ændrew Rininsland
60 changed files with 408 additions and 259 deletions
@ -0,0 +1,101 @@
|
||||
import CLASS from './class' |
||||
import { c3_chart_internal_fn } from './core'; |
||||
|
||||
c3_chart_internal_fn.generateClass = function (prefix, targetId) { |
||||
return " " + prefix + " " + prefix + this.getTargetSelectorSuffix(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 targetId || targetId === 0 ? ('-' + targetId).replace(/[\s?!@#$%^&*()_=+,.<>'":;\[\]\/|~`{}\\]/g, '-') : ''; |
||||
}; |
||||
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; |
||||
}; |
@ -1,4 +0,0 @@
|
||||
(function (window) { |
||||
'use strict'; |
||||
|
||||
/*global define, module, exports, require */ |
@ -0,0 +1,58 @@
|
||||
import { c3 } from './core' |
||||
|
||||
import './polyfill'; |
||||
|
||||
import './api.axis'; |
||||
import './api.category'; |
||||
import './api.chart'; |
||||
import './api.color'; |
||||
import './api.data'; |
||||
import './api.flow'; |
||||
import './api.focus'; |
||||
import './api.grid'; |
||||
import './api.group'; |
||||
import './api.legend'; |
||||
import './api.load'; |
||||
import './api.region'; |
||||
import './api.selection'; |
||||
import './api.show'; |
||||
import './api.tooltip'; |
||||
import './api.transform'; |
||||
import './api.x'; |
||||
import './api.zoom'; |
||||
import './arc'; |
||||
import './axis'; |
||||
import './c3.axis'; |
||||
import './cache'; |
||||
import './category'; |
||||
import './class'; |
||||
import './class-utils'; |
||||
import './clip'; |
||||
import './color'; |
||||
import './config'; |
||||
import './data.convert'; |
||||
import './data'; |
||||
import './data.load'; |
||||
import './domain'; |
||||
import './drag'; |
||||
import './format'; |
||||
import './grid'; |
||||
import './interaction'; |
||||
import './legend'; |
||||
import './region'; |
||||
import './scale'; |
||||
import './selection'; |
||||
import './shape.bar'; |
||||
import './shape'; |
||||
import './shape.line'; |
||||
import './size'; |
||||
import './subchart'; |
||||
import './text'; |
||||
import './title'; |
||||
import './tooltip'; |
||||
import './type'; |
||||
import './ua'; |
||||
import './util'; |
||||
import './zoom'; |
||||
|
||||
export default c3 |
@ -1,9 +0,0 @@
|
||||
if (typeof define === 'function' && define.amd) { |
||||
define("c3", ["d3"], function () { return c3; }); |
||||
} else if ('undefined' !== typeof exports && 'undefined' !== typeof module) { |
||||
module.exports = c3; |
||||
} else { |
||||
window.c3 = c3; |
||||
} |
||||
|
||||
})(window); |
@ -1,49 +1,51 @@
|
||||
var isValue = c3_chart_internal_fn.isValue = function (v) { |
||||
import { c3_chart_internal_fn } from './core'; |
||||
|
||||
export var isValue = function (v) { |
||||
return v || v === 0; |
||||
}, |
||||
isFunction = c3_chart_internal_fn.isFunction = function (o) { |
||||
return typeof o === 'function'; |
||||
}, |
||||
isString = c3_chart_internal_fn.isString = function (o) { |
||||
return typeof o === 'string'; |
||||
}, |
||||
isUndefined = c3_chart_internal_fn.isUndefined = function (v) { |
||||
return typeof v === 'undefined'; |
||||
}, |
||||
isDefined = c3_chart_internal_fn.isDefined = function (v) { |
||||
return typeof v !== 'undefined'; |
||||
}, |
||||
ceil10 = c3_chart_internal_fn.ceil10 = function (v) { |
||||
return Math.ceil(v / 10) * 10; |
||||
}, |
||||
asHalfPixel = c3_chart_internal_fn.asHalfPixel = function (n) { |
||||
return Math.ceil(n) + 0.5; |
||||
}, |
||||
diffDomain = c3_chart_internal_fn.diffDomain = function (d) { |
||||
return d[1] - d[0]; |
||||
}, |
||||
isEmpty = c3_chart_internal_fn.isEmpty = function (o) { |
||||
return typeof o === 'undefined' || o === null || (isString(o) && o.length === 0) || (typeof o === 'object' && Object.keys(o).length === 0); |
||||
}, |
||||
notEmpty = c3_chart_internal_fn.notEmpty = function (o) { |
||||
return !c3_chart_internal_fn.isEmpty(o); |
||||
}, |
||||
getOption = c3_chart_internal_fn.getOption = function (options, key, defaultValue) { |
||||
return isDefined(options[key]) ? options[key] : defaultValue; |
||||
}, |
||||
hasValue = c3_chart_internal_fn.hasValue = function (dict, value) { |
||||
var found = false; |
||||
Object.keys(dict).forEach(function (key) { |
||||
if (dict[key] === value) { found = true; } |
||||
}); |
||||
return found; |
||||
}, |
||||
sanitise = c3_chart_internal_fn.sanitise = function (str) { |
||||
return typeof str === 'string' ? str.replace(/</g, '<').replace(/>/g, '>') : str; |
||||
}, |
||||
getPathBox = c3_chart_internal_fn.getPathBox = function (path) { |
||||
var box = path.getBoundingClientRect(), |
||||
items = [path.pathSegList.getItem(0), path.pathSegList.getItem(1)], |
||||
minX = items[0].x, minY = Math.min(items[0].y, items[1].y); |
||||
return {x: minX, y: minY, width: box.width, height: box.height}; |
||||
}; |
||||
}; |
||||
export var isFunction = function (o) { |
||||
return typeof o === 'function'; |
||||
}; |
||||
export var isString = function (o) { |
||||
return typeof o === 'string'; |
||||
}; |
||||
export var isUndefined = function (v) { |
||||
return typeof v === 'undefined'; |
||||
}; |
||||
export var isDefined = function (v) { |
||||
return typeof v !== 'undefined'; |
||||
}; |
||||
export var ceil10 = function (v) { |
||||
return Math.ceil(v / 10) * 10; |
||||
}; |
||||
export var asHalfPixel = function (n) { |
||||
return Math.ceil(n) + 0.5; |
||||
}; |
||||
export var diffDomain = function (d) { |
||||
return d[1] - d[0]; |
||||
}; |
||||
export var isEmpty = function (o) { |
||||
return typeof o === 'undefined' || o === null || (isString(o) && o.length === 0) || (typeof o === 'object' && Object.keys(o).length === 0); |
||||
}; |
||||
export var notEmpty = function (o) { |
||||
return !c3_chart_internal_fn.isEmpty(o); |
||||
}; |
||||
export var getOption = function (options, key, defaultValue) { |
||||
return isDefined(options[key]) ? options[key] : defaultValue; |
||||
}; |
||||
export var hasValue = function (dict, value) { |
||||
var found = false; |
||||
Object.keys(dict).forEach(function (key) { |
||||
if (dict[key] === value) { found = true; } |
||||
}); |
||||
return found; |
||||
}; |
||||
export var sanitise = function (str) { |
||||
return typeof str === 'string' ? str.replace(/</g, '<').replace(/>/g, '>') : str; |
||||
}; |
||||
export var getPathBox = function (path) { |
||||
var box = path.getBoundingClientRect(), |
||||
items = [path.pathSegList.getItem(0), path.pathSegList.getItem(1)], |
||||
minX = items[0].x, minY = Math.min(items[0].y, items[1].y); |
||||
return {x: minX, y: minY, width: box.width, height: box.height}; |
||||
}; |
||||
|
Loading…
Reference in new issue