Commit fdcb1ab8 authored by Masayuki Tanaka's avatar Masayuki Tanaka

Fix bindto - #218

parent 64af0b87
...@@ -289,7 +289,8 @@ ...@@ -289,7 +289,8 @@
/*-- Set Variables --*/ /*-- Set Variables --*/
var clipId = (typeof __bindto === "string" ? __bindto.replace('#', '') : __bindto.id) + '-clip', // MEMO: clipId needs to be unique because it conflicts when multiple charts exist
var clipId = (typeof __bindto === "string" ? __bindto.replace(/[# .>~+]/g, '') : CLASS.chart + (+new Date())) + '-clip',
clipIdForXAxis = clipId + '-xaxis', clipIdForXAxis = clipId + '-xaxis',
clipIdForYAxis = clipId + '-yaxis', clipIdForYAxis = clipId + '-yaxis',
clipPath = getClipPath(clipId), clipPath = getClipPath(clipId),
...@@ -489,7 +490,7 @@ ...@@ -489,7 +490,7 @@
var leftAxisClass = __axis_rotated ? CLASS.axisX : CLASS.axisY, var leftAxisClass = __axis_rotated ? CLASS.axisX : CLASS.axisY,
leftAxis = main.select('.' + leftAxisClass).node(), leftAxis = main.select('.' + leftAxisClass).node(),
svgRect = leftAxis ? leftAxis.getBoundingClientRect() : {right: 0}, svgRect = leftAxis ? leftAxis.getBoundingClientRect() : {right: 0},
chartRect = d3.select(__bindto).node().getBoundingClientRect(), chartRect = selectChart.node().getBoundingClientRect(),
hasArc = hasArcType(c3.data.targets), hasArc = hasArcType(c3.data.targets),
svgLeft = svgRect.right - chartRect.left - (hasArc ? 0 : getCurrentPaddingLeft()); svgLeft = svgRect.right - chartRect.left - (hasArc ? 0 : getCurrentPaddingLeft());
return svgLeft > 0 ? svgLeft : 0; return svgLeft > 0 ? svgLeft : 0;
...@@ -538,10 +539,10 @@ ...@@ -538,10 +539,10 @@
return (getAxisLabelPositionById(axisId).isInner ? 30 : 40) + (axisId === 'y2' ? -10 : 0); return (getAxisLabelPositionById(axisId).isInner ? 30 : 40) + (axisId === 'y2' ? -10 : 0);
} }
function getParentWidth() { function getParentWidth() {
return +d3.select(__bindto).style("width").replace('px', ''); // TODO: if rotated, use height return +selectChart.style("width").replace('px', ''); // TODO: if rotated, use height
} }
function getParentHeight() { function getParentHeight() {
return +d3.select(__bindto).style('height').replace('px', ''); // TODO: if rotated, use width return +selectChart.style('height').replace('px', ''); // TODO: if rotated, use width
} }
function getAxisClipX(forHorizontal) { function getAxisClipX(forHorizontal) {
// axis line width + padding for left // axis line width + padding for left
...@@ -2448,7 +2449,7 @@ ...@@ -2448,7 +2449,7 @@
selectChart = d3.select(__bindto); selectChart = d3.select(__bindto);
if (selectChart.empty()) { if (selectChart.empty()) {
throw new Error('Bind element not found. Check the selector specified by "bindto" and existance of that element. Default "bindto" is "#chart".'); throw new Error('Element to bind not found');
} }
selectChart.html("").classed("c3", true); selectChart.html("").classed("c3", true);
...@@ -2513,7 +2514,7 @@ ...@@ -2513,7 +2514,7 @@
} }
// Define tooltip // Define tooltip
tooltip = d3.select(__bindto) tooltip = selectChart
.style("position", "relative") .style("position", "relative")
.append("div") .append("div")
.style("position", "absolute") .style("position", "absolute")
......
This source diff could not be displayed because it is too large. You can view the blob instead.
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