Commit f9107767 authored by Masayuki Tanaka's avatar Masayuki Tanaka Committed by masayuki

Add spline type

parent 434af4b8
...@@ -230,6 +230,7 @@ ...@@ -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 @@ ...@@ -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 @@ ...@@ -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)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment