Browse Source

Fix clipId to unique for each chart - #109 #110

pull/116/merge
Masayuki Tanaka 11 years ago
parent
commit
e44ce25b1f
  1. 20
      c3.js
  2. 4
      c3.min.js

20
c3.js

@ -259,7 +259,11 @@
/*-- Set Variables --*/ /*-- Set Variables --*/
var clipId = (typeof __bindto === "string" ? __bindto.replace('#', '') : __bindto.id) + '-clip', var clipId = (typeof __bindto === "string" ? __bindto.replace('#', '') : __bindto.id) + '-clip',
clipPath = getClipPath(clipId); clipIdForXAxis = clipId + '-xaxis',
clipIdForYAxis = clipId + '-yaxis',
clipPath = getClipPath(clipId),
clipPathForXAxis = getClipPath(clipPathForXAxis),
clipPathForYAxis = getClipPath(clipPathForYAxis);
var isTimeSeries = (__axis_x_type === 'timeseries'), var isTimeSeries = (__axis_x_type === 'timeseries'),
isCategorized = (__axis_x_type === 'categorized'), isCategorized = (__axis_x_type === 'categorized'),
@ -2308,14 +2312,14 @@
.attr("width", width) .attr("width", width)
.attr("height", height); .attr("height", height);
defs.append("clipPath") defs.append("clipPath")
.attr("id", "xaxis-clip") .attr("id", clipIdForXAxis)
.append("rect") .append("rect")
.attr("x", getXAxisClipX) .attr("x", getXAxisClipX)
.attr("y", getXAxisClipY) .attr("y", getXAxisClipY)
.attr("width", getXAxisClipWidth) .attr("width", getXAxisClipWidth)
.attr("height", getXAxisClipHeight); .attr("height", getXAxisClipHeight);
defs.append("clipPath") defs.append("clipPath")
.attr("id", "yaxis-clip") .attr("id", clipIdForYAxis)
.append("rect") .append("rect")
.attr("x", getYAxisClipX) .attr("x", getYAxisClipX)
.attr("y", getYAxisClipY) .attr("y", getYAxisClipY)
@ -2341,7 +2345,7 @@
// Add Axis // Add Axis
main.append("g") main.append("g")
.attr("class", CLASS.axisX) .attr("class", CLASS.axisX)
.attr("clip-path", __axis_rotated ? "" : getClipPath("xaxis-clip")) .attr("clip-path", __axis_rotated ? "" : clipPathForXAxis)
.attr("transform", translate.x) .attr("transform", translate.x)
.append("text") .append("text")
.attr("class", CLASS.axisXLabel) .attr("class", CLASS.axisXLabel)
@ -2353,7 +2357,7 @@
if (__axis_y_show) { if (__axis_y_show) {
main.append("g") main.append("g")
.attr("class", CLASS.axisY) .attr("class", CLASS.axisY)
.attr("clip-path", __axis_rotated ? getClipPath("yaxis-clip") : "") .attr("clip-path", __axis_rotated ? clipPathForYAxis : "")
.append("text") .append("text")
.attr("class", CLASS.axisYLabel) .attr("class", CLASS.axisYLabel)
.attr("transform", __axis_rotated ? "" : "rotate(-90)") .attr("transform", __axis_rotated ? "" : "rotate(-90)")
@ -2486,7 +2490,7 @@
context.append("g") context.append("g")
.attr("class", CLASS.axisX) .attr("class", CLASS.axisX)
.attr("transform", translate.subx) .attr("transform", translate.subx)
.attr("clip-path", __axis_rotated ? "" : getClipPath("xaxis-clip")); .attr("clip-path", __axis_rotated ? "" : clipPathForXAxis);
} }
// Set targets // Set targets
@ -3250,8 +3254,8 @@
function updateSvgSize() { function updateSvgSize() {
svg.attr('width', currentWidth).attr('height', currentHeight); svg.attr('width', currentWidth).attr('height', currentHeight);
svg.select('#' + clipId).select('rect').attr('width', width).attr('height', height); svg.select('#' + clipId).select('rect').attr('width', width).attr('height', height);
svg.select('#xaxis-clip').select('rect').attr('width', getXAxisClipWidth); svg.select('#' + clipIdForXAxis).select('rect').attr('width', getXAxisClipWidth);
svg.select('#yaxis-clip').select('rect').attr('width', getYAxisClipWidth); svg.select('#' + clipIdForYAxis).select('rect').attr('width', getYAxisClipWidth);
svg.select('.' + CLASS.zoomRect).attr('width', width).attr('height', height); svg.select('.' + CLASS.zoomRect).attr('width', width).attr('height', height);
} }

4
c3.min.js vendored

File diff suppressed because one or more lines are too long
Loading…
Cancel
Save