Browse Source

Fix spec

pull/1577/merge
Masayuki Tanaka 9 years ago
parent
commit
aed7d243ef
  1. 12
      c3.css
  2. 6
      c3.js
  3. 10
      c3.min.js
  4. 8
      spec/axis-spec.js
  5. 6
      src/axis.js

12
c3.css

@ -1,7 +1,7 @@
/*-- Chart --*/ /*-- Chart --*/
.c3 svg { .c3 svg {
font: 10px sans-serif; font: 10px sans-serif;
-webkit-tap-highlight-color: transparent; } -webkit-tap-highlight-color: rgba(0, 0, 0, 0); }
.c3 path, .c3 line { .c3 path, .c3 line {
fill: none; fill: none;
@ -12,11 +12,7 @@
-moz-user-select: none; -moz-user-select: none;
user-select: none; } user-select: none; }
.c3-legend-item-tile, .c3-legend-item-tile, .c3-xgrid-focus, .c3-ygrid, .c3-event-rect, .c3-bars path {
.c3-xgrid-focus,
.c3-ygrid,
.c3-event-rect,
.c3-bars path {
shape-rendering: crispEdges; } shape-rendering: crispEdges; }
.c3-chart-arc path { .c3-chart-arc path {
@ -75,11 +71,11 @@
/*-- Region --*/ /*-- Region --*/
.c3-region { .c3-region {
fill: steelblue; fill: steelblue;
fill-opacity: .1; } fill-opacity: 0.1; }
/*-- Brush --*/ /*-- Brush --*/
.c3-brush .extent { .c3-brush .extent {
fill-opacity: .1; } fill-opacity: 0.1; }
/*-- Select - Drag --*/ /*-- Select - Drag --*/
/*-- Legend --*/ /*-- Legend --*/

6
c3.js

@ -4415,11 +4415,9 @@
withoutTransition: withoutTransition, withoutTransition: withoutTransition,
tickTextRotate: withoutRotateTickText ? 0 : config.axis_y_tick_rotate tickTextRotate: withoutRotateTickText ? 0 : config.axis_y_tick_rotate
}, },
d3 = $$.d3, axis = c3_axis($$.d3, axisParams).scale(scale).orient(orient).tickFormat(tickFormat);
config = $$.config,
axis = c3_axis(d3, axisParams).scale(scale).orient(orient).tickFormat(tickFormat);
if ($$.isTimeSeriesY()) { if ($$.isTimeSeriesY()) {
axis.ticks(d3.time[config.axis_y_tick_time_value], config.axis_y_tick_time_interval); axis.ticks($$.d3.time[config.axis_y_tick_time_value], config.axis_y_tick_time_interval);
} else { } else {
axis.tickValues(tickValues); axis.tickValues(tickValues);
} }

10
c3.min.js vendored

File diff suppressed because one or more lines are too long

8
spec/axis-spec.js

@ -153,7 +153,7 @@ describe('c3 chart axis', function () {
describe('axis.x.tick.values', function () { describe('axis.x.tick.values', function () {
describe('function is provided', function () { describe('function is provided', function () {
var tickGenerator = function (/*domain*/) { var tickGenerator = function () {
var values = []; var values = [];
for (var i = 0; i <= 300; i += 50) { for (var i = 0; i <= 300; i += 50) {
values.push(i); values.push(i);
@ -599,7 +599,6 @@ describe('c3 chart axis', function () {
}); });
}); });
describe('axis.y.tick.rotate', function () { describe('axis.y.tick.rotate', function () {
describe('not rotated', function () { describe('not rotated', function () {
@ -613,6 +612,7 @@ describe('c3 chart axis', function () {
] ]
}, },
axis: { axis: {
rotated: true,
y: { y: {
tick: { tick: {
rotate: 45 rotate: 45
@ -630,13 +630,13 @@ describe('c3 chart axis', function () {
tspan = text.select('tspan'); tspan = text.select('tspan');
expect(text.attr('transform')).toBe('rotate(45)'); expect(text.attr('transform')).toBe('rotate(45)');
expect(text.attr('y')).toBe('4'); expect(text.attr('y')).toBe('4');
expect(tspan.attr('dx')).toBe('5.65685424949238'); expect(tspan.attr('dx')).toBeCloseTo('5.6', 0);
}); });
}); });
it('should have automatically calculated y axis width', function () { it('should have automatically calculated y axis width', function () {
var box = chart.internal.main.select('.c3-axis-y').node().getBoundingClientRect(); var box = chart.internal.main.select('.c3-axis-y').node().getBoundingClientRect();
expect(box.width).toBeLessThan(25); expect(box.width).toBeCloseTo(590, 1);
}); });
}); });

6
src/axis.js

@ -83,11 +83,9 @@ Axis.prototype.getYAxis = function getYAxis(scale, orient, tickFormat, tickValue
withoutTransition: withoutTransition, withoutTransition: withoutTransition,
tickTextRotate: withoutRotateTickText ? 0 : config.axis_y_tick_rotate tickTextRotate: withoutRotateTickText ? 0 : config.axis_y_tick_rotate
}, },
d3 = $$.d3, axis = c3_axis($$.d3, axisParams).scale(scale).orient(orient).tickFormat(tickFormat);
config = $$.config,
axis = c3_axis(d3, axisParams).scale(scale).orient(orient).tickFormat(tickFormat);
if ($$.isTimeSeriesY()) { if ($$.isTimeSeriesY()) {
axis.ticks(d3.time[config.axis_y_tick_time_value], config.axis_y_tick_time_interval); axis.ticks($$.d3.time[config.axis_y_tick_time_value], config.axis_y_tick_time_interval);
} else { } else {
axis.tickValues(tickValues); axis.tickValues(tickValues);
} }

Loading…
Cancel
Save