Browse Source

Add spline type

pull/1/head
Masayuki Tanaka 12 years ago committed by masayuki
parent
commit
f91077679a
  1. 12
      c3.js

12
c3.js

@ -230,6 +230,7 @@
return function (d) { return function (d) {
var x0, y0 var x0, y0
if (isLineType(d)) { if (isLineType(d)) {
isSplineType(d) ? line.interpolate("cardinal") : line.interpolate("linear")
return __data_regions.length > 0 ? lineWithRegions(d.values, x, getYScale(d.id), __data_regions[d.id]) : line(d.values) return __data_regions.length > 0 ? lineWithRegions(d.values, x, getYScale(d.id), __data_regions[d.id]) : line(d.values)
} else { } else {
x0 = x(d.values[0].x) x0 = x(d.values[0].x)
@ -584,7 +585,11 @@
} }
function isLineType (d) { function isLineType (d) {
var id = (typeof d === 'string') ? d : d.id var id = (typeof d === 'string') ? d : d.id
return !(id in __data_types) || __data_types[id] === 'line' return !(id in __data_types) || __data_types[id] === 'line' || __data_types[id] === 'spline'
}
function isSplineType (d) {
var id = (typeof d === 'string') ? d : d.id
return __data_types[id] === 'spline'
} }
function isBarType (d) { function isBarType (d) {
var id = (typeof d === 'string') ? d : d.id var id = (typeof d === 'string') ? d : d.id
@ -1552,6 +1557,11 @@
redraw(true, true, true) redraw(true, true, true)
} }
c3.toSpline = function (targets) {
setTargetType(targets, 'spline')
redraw(true, true, true)
}
c3.toBar = function (targets) { c3.toBar = function (targets) {
setTargetType(targets, 'bar') setTargetType(targets, 'bar')
redraw(true, true, true) redraw(true, true, true)

Loading…
Cancel
Save