Browse Source

Fix grid x lines

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

27
c3.js

@ -487,6 +487,9 @@
function xx (d) { function xx (d) {
return x(d.x) return x(d.x)
} }
function xv (d) {
return x(d.value)
}
function yv (d) { function yv (d) {
return y(d.value) return y(d.value)
} }
@ -756,15 +759,16 @@
.attr("class", "xgrid-line") .attr("class", "xgrid-line")
xgridLine.append('line') xgridLine.append('line')
.attr("class", function(d){ return "" + d['class'] }) .attr("class", function(d){ return "" + d['class'] })
.attr("x1", function(d){ return x(d.value) }) .attr("x1", __axis_rotated ? 0 : xv)
.attr("x2", function(d){ return x(d.value) }) .attr("x2", __axis_rotated ? width : xv)
.attr("y1", margin.top) .attr("y1", __axis_rotated ? xv : margin.top)
.attr("y2", height) .attr("y2", __axis_rotated ? xv : height)
xgridLine.append('text') xgridLine.append('text')
.attr("class", function(d){ return "" + d['class'] }) .attr("class", function(d){ return "" + d['class'] })
.attr('x', function(d){ return x(d.value) }) .attr("text-anchor", "end")
.attr('y', height-8) .attr("transform", __axis_rotated ? "" : "rotate(-90)")
.attr('dx', 6) .attr('dx', __axis_rotated ? 0 : -margin.top)
.attr('dy', -6)
.text(function(d){ return d.text }) .text(function(d){ return d.text })
} }
if (__point_focus_line_enabled) { if (__point_focus_line_enabled) {
@ -1138,10 +1142,13 @@
if (__grid_x_lines) { if (__grid_x_lines) {
xgridLine = main.selectAll(".xgrid-lines") xgridLine = main.selectAll(".xgrid-lines")
xgridLine.selectAll('line') xgridLine.selectAll('line')
.attr("x1", function(d){ return x(d.value) }) .attr("x1", __axis_rotated ? 0 : xv)
.attr("x2", function(d){ return x(d.value) }) .attr("x2", __axis_rotated ? width : xv)
.attr("y1", __axis_rotated ? xv : margin.top)
.attr("y2", __axis_rotated ? xv : height)
xgridLine.selectAll('text') xgridLine.selectAll('text')
.attr("x", function(d){ return x(d.value) }) .attr("x", __axis_rotated ? width : 0)
.attr("y", xv)
} }
// Y-Grid // Y-Grid
if (withY && __grid_y_show) { if (withY && __grid_y_show) {

Loading…
Cancel
Save