提交 5e3ed2b2 编写于 作者: P pissang

optimize default position of grid to avoid overlap with dataZoom

上级 7da95dba
......@@ -136,7 +136,7 @@ class LineSeriesModel extends SeriesModel<LineSeriesOption> {
static defaultOption: LineSeriesOption = {
zlevel: 0,
z: 2,
z: 3,
coordinateSystem: 'cartesian2d',
legendHoverLink: true,
......
......@@ -38,7 +38,7 @@ import CoordinateSystemManager from '../../CoordinateSystem';
import {ParsedModelFinder, SINGLE_REFERRING} from '../../util/model';
// Depends on GridModel, AxisModel, which performs preprocess.
import GridModel from './GridModel';
import GridModel, {defaultGridLayoutWithoutLabel, defaultGridLayoutWithLabel} from './GridModel';
import CartesianAxisModel from './AxisModel';
import GlobalModel from '../../model/Global';
import ExtensionAPI from '../../ExtensionAPI';
......@@ -118,8 +118,19 @@ class Grid implements CoordinateSystemMaster {
*/
resize(gridModel: GridModel, api: ExtensionAPI, ignoreContainLabel?: boolean): void {
const boxLayoutParams = gridModel.getBoxLayoutParams();
const isContainLabel = !ignoreContainLabel && gridModel.get('containLabel');
each(defaultGridLayoutWithoutLabel, function (val, key) {
if (boxLayoutParams[key] == null || boxLayoutParams[key] === 'auto') {
boxLayoutParams[key] = isContainLabel
? defaultGridLayoutWithLabel[key]
: defaultGridLayoutWithoutLabel[key];
}
});
const gridRect = getLayoutRect(
gridModel.getBoxLayoutParams(), {
boxLayoutParams, {
width: api.getWidth(),
height: api.getHeight()
});
......@@ -131,7 +142,7 @@ class Grid implements CoordinateSystemMaster {
adjustAxes();
// Minus label size
if (!ignoreContainLabel && gridModel.get('containLabel')) {
if (isContainLabel) {
each(axesList, function (axis) {
if (!axis.model.get(['axisLabel', 'inside'])) {
const labelUnionRect = estimateLabelUnionRect(axis);
......
......@@ -37,6 +37,20 @@ export interface GridOption extends ComponentOption, BoxLayoutOptionMixin, Shado
tooltip?: any; // FIXME:TS add this tooltip type
}
export const defaultGridLayoutWithoutLabel = {
left: '10%',
top: 60,
right: '10%',
bottom: 70
} as const;
export const defaultGridLayoutWithLabel = {
left: '5%',
top: 60,
right: '5%',
bottom: 55
} as const;
class GridModel extends ComponentModel<GridOption> implements CoordinateSystemHostModel {
static type = 'grid';
......@@ -51,10 +65,6 @@ class GridModel extends ComponentModel<GridOption> implements CoordinateSystemHo
show: false,
zlevel: 0,
z: 0,
left: '10%',
top: 60,
right: '10%',
bottom: 60,
// If grid size contain label
containLabel: false,
// width: {totalWidth} - left - right,
......
......@@ -76,7 +76,6 @@ export default {
stateAnimation: {
duration: 300,
easing: 'cubicOut'
// additive: true
},
animation: 'auto',
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册