Browse Source

Fix x axis tick values

pull/127/head
Masayuki Tanaka 11 years ago
parent
commit
1987be65cf
  1. 16
      c3.js
  2. 4
      c3.min.js

16
c3.js

@ -624,7 +624,7 @@
return id in __data_axes ? __data_axes[id] : 'y'; return id in __data_axes ? __data_axes[id] : 'y';
} }
function getXAxisTickFormat() { function getXAxisTickFormat() {
var format = isTimeSeries ? defaultTimeFormat : isCategorized ? category : null; var format = isTimeSeries ? defaultTimeFormat : isCategorized ? categoryName : function (v) { return v < 0 ? v.toFixed(0) : v; };
if (__axis_x_tick_format) { if (__axis_x_tick_format) {
if (typeof __axis_x_tick_format === 'function') { if (typeof __axis_x_tick_format === 'function') {
format = __axis_x_tick_format; format = __axis_x_tick_format;
@ -1514,7 +1514,7 @@
function hasPositiveValueInTargets(targets) { function hasPositiveValueInTargets(targets) {
return checkValueInTargets(targets, function (v) { return v > 0; }); return checkValueInTargets(targets, function (v) { return v > 0; });
} }
function category(i) { function categoryName(i) {
return i < __axis_x_categories.length ? __axis_x_categories[i] : i; return i < __axis_x_categories.length ? __axis_x_categories[i] : i;
} }
function generateClass(prefix, targetId) { function generateClass(prefix, targetId) {
@ -2900,10 +2900,12 @@
if (withUpdateXDomain) { if (withUpdateXDomain) {
x.domain(brush.empty() ? orgXDomain : brush.extent()); x.domain(brush.empty() ? orgXDomain : brush.extent());
if (__zoom_enabled) { zoom.scale(x).updateScaleExtent(); } if (__zoom_enabled) { zoom.scale(x).updateScaleExtent(); }
// update axis tick values according to options // update axis tick values according to options, except for scatter plot
tickValues = generateTickValues(mapTargetsToUniqueXs(targetsToShow)); if (! hasScatterType(targetsToShow)) { // TODO: fix this
xAxis.tickValues(tickValues); tickValues = generateTickValues(mapTargetsToUniqueXs(targetsToShow));
subXAxis.tickValues(tickValues); xAxis.tickValues(tickValues);
subXAxis.tickValues(tickValues);
}
} }
y.domain(getYDomain(targetsToShow, 'y')); y.domain(getYDomain(targetsToShow, 'y'));
y2.domain(getYDomain(targetsToShow, 'y2')); y2.domain(getYDomain(targetsToShow, 'y2'));
@ -2914,7 +2916,7 @@
main.select('.' + CLASS.axisY2).style("opacity", hideAxis ? 0 : 1).transition().duration(durationForAxis).call(yAxis2); main.select('.' + CLASS.axisY2).style("opacity", hideAxis ? 0 : 1).transition().duration(durationForAxis).call(yAxis2);
// show/hide if manual culling needed // show/hide if manual culling needed
if (withUpdateXDomain && __axis_x_tick_culling) { if (withUpdateXDomain && __axis_x_tick_culling && tickValues) {
for (i = 1; i < tickValues.length; i++) { for (i = 1; i < tickValues.length; i++) {
if (tickValues.length / i < __axis_x_tick_culling_max) { if (tickValues.length / i < __axis_x_tick_culling_max) {
intervalForCulling = i; intervalForCulling = i;

4
c3.min.js vendored

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