Commit 11fa684a authored by Evgeny's avatar Evgeny

Move lines

parent ba260653
...@@ -57,6 +57,7 @@ module.exports = (grunt) -> ...@@ -57,6 +57,7 @@ module.exports = (grunt) ->
'src/callbacks.js', 'src/callbacks.js',
'src/class.js', 'src/class.js',
'src/util.js', 'src/util.js',
'src/lines.js',
'src/api.focus.js', 'src/api.focus.js',
'src/api.title.js', 'src/api.title.js',
'src/api.show.js', 'src/api.show.js',
......
...@@ -114,3 +114,10 @@ c3_chart_fn.getValue = function(id, i){ ...@@ -114,3 +114,10 @@ c3_chart_fn.getValue = function(id, i){
return t.values[i].value; return t.values[i].value;
}; };
c3.chart.fn.update_x = function(x){
var $$ = this.internal;
$$.api.x(copyArray(x));
$$.tuneAxis();
};
...@@ -18,7 +18,7 @@ c3.chart.internal.fn.getLineCoordsForBar = function(center, order){ ...@@ -18,7 +18,7 @@ c3.chart.internal.fn.getLineCoordsForBar = function(center, order){
var x1, x2, y1, y2; var x1, x2, y1, y2;
if(utils.isSub($$.config.ed3Type)){ if(isSub($$.config.ed3Type)){
$$.ed3Config.subBox = $$.getBox($$.main.selectAll(".sub-chart .c3-chart-bars")); $$.ed3Config.subBox = $$.getBox($$.main.selectAll(".sub-chart .c3-chart-bars"));
...@@ -88,7 +88,7 @@ c3.chart.internal.fn.getLineCoordsForPie = function(center, order){ ...@@ -88,7 +88,7 @@ c3.chart.internal.fn.getLineCoordsForPie = function(center, order){
var x1, x2, y1, y2; var x1, x2, y1, y2;
if(utils.isSub($$.config.ed3Type)){ if(isSub($$.config.ed3Type)){
if(!$$.ed3Config.coords) return; if(!$$.ed3Config.coords) return;
...@@ -189,7 +189,7 @@ c3.chart.internal.fn.redrawLines = function(){ ...@@ -189,7 +189,7 @@ c3.chart.internal.fn.redrawLines = function(){
line = main.selectAll(".lineForSubChart").filter(function(d, i){ return i === 0; }); line = main.selectAll(".lineForSubChart").filter(function(d, i){ return i === 0; });
} }
center = $$.getCenter(main.selectAll('.c3-chart')); var center = $$.getCenter(main.selectAll('.c3-chart'));
var coords; var coords;
......
...@@ -52,5 +52,55 @@ var isValue = c3_chart_internal_fn.isValue = function (v) { ...@@ -52,5 +52,55 @@ var isValue = c3_chart_internal_fn.isValue = function (v) {
}, },
toDegrees = function(radians){ toDegrees = function(radians){
return radians * (180 / Math.PI); return radians * (180 / Math.PI);
},
isSub = function(type){
if(!type){
return false;
}
return type.indexOf("sub") > -1;
},
copyObject = function(oldObj){
var newObj = {};
for(var key in oldObj){
if(oldObj.hasOwnProperty(key)){
newObj[key] = oldObj[key];
}
}
return newObj;
},
copyArray = function(oldArray){
var newArray = [];
oldArray.forEach(function(elem){
if(typeof elem === 'function'){
newArray.push(copyFunction(elem));
} else if(Array.isArray(elem)){
newArray.push(copyArray(elem));
} else if(typeof elem === 'object'){
newArray.push(copyObject(elem));
} else {
newArray.push(elem);
}
});
return newArray;
},
copyFunction = function(oldFunction){
var cloneObj = oldFunction;
if(oldFunction.__isClone) {
cloneObj = oldFunction.__clonedFrom;
}
var temp = function() { return cloneObj.apply(oldFunction, arguments); };
for(var key in oldFunction) {
temp[key] = oldFunction[key];
}
temp.__isClone = true;
temp.__clonedFrom = cloneObj;
return temp;
}; };
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