Skip to content

Commit

Permalink
Refactor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
c-okelly committed Nov 15, 2017
1 parent c55ea20 commit d230e35
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
12 changes: 6 additions & 6 deletions src/coord/axisHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import OrdinalScale from '../scale/Ordinal';
import IntervalScale from '../scale/Interval';
import Scale from '../scale/Scale';
import * as numberUtil from '../util/number';
import {calBarWidthAndOffset} from '../layout/barGrid';

import '../scale/Time';
import '../scale/Log';
import '../layout/barGrid';

/**
* Get axis scale extent before niced.
Expand Down Expand Up @@ -115,27 +115,27 @@ export function getScaleExtent(scale, model) {
// If bars are placed on a base axis of type time or interval account for axis boundary overflow and current axis is base axis
var ecModel = model.getModel().ecModel;
var numberBarPlots = ecModel.getSeriesByType("bar").length;
var isBaseAxis = model.ecModel._componentsMap._ec_series.map(function(x){ return x.getBaseAxis() === model.axis}).indexOf(true) !== -1;
var isBaseAxis = model.ecModel.getSeries().map(function(x){ return x.getBaseAxis() === model.axis}).indexOf(true) !== -1;
if ((scaleType === 'time' || scaleType === 'interval') && numberBarPlots > 0 && isBaseAxis){

// Adjust axis min and max to account for overflow
var adjustedScale = axisHelper.adjustScaleForOverflow(min, max, model);
var adjustedScale = adjustScaleForOverflow(min, max, model);
min = adjustedScale.min;
max = adjustedScale.max;
}

return [min, max];
}

axisHelper.adjustScaleForOverflow = function (min, max, model) {
export function adjustScaleForOverflow(min, max, model) {

var ecModel = model.getModel().ecModel;
// Get Axis Length
var axisExtent = model.axis._extent;
var axisExtent = model.axis.getExtent();
var axisLength = axisExtent[1] - axisExtent[0]

// Calculate placement of bars on axis
var barWidthAndOffset = barGrid.calBarWidthAndOffset(zrUtil.filter(
var barWidthAndOffset = calBarWidthAndOffset(zrUtil.filter(
ecModel.getSeriesByType('bar'),
function (seriesModel) {
return !ecModel.isSeriesFiltered(seriesModel)
Expand Down
3 changes: 1 addition & 2 deletions src/layout/barGrid.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ function getLayoutOnAxis(opt, api) {
return result;
}

function calBarWidthAndOffset(barSeries, api) {
export function calBarWidthAndOffset(barSeries, api) {
var seriesInfoList = zrUtil.map(barSeries, function (seriesModel) {
var data = seriesModel.getData();
var cartesian = seriesModel.coordinateSystem;
Expand Down Expand Up @@ -318,6 +318,5 @@ function barLayoutGrid(seriesType, ecModel, api) {
}

barLayoutGrid.getLayoutOnAxis = getLayoutOnAxis;
barLayoutGrid.calBarWidthAndOffset = calBarWidthAndOffset;

export default barLayoutGrid;

0 comments on commit d230e35

Please sign in to comment.