You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@echarts.apache.org by sh...@apache.org on 2020/10/20 10:40:39 UTC
[incubator-echarts] 01/02: optimize default position of grid to
avoid overlap with dataZoom
This is an automated email from the ASF dual-hosted git repository.
shenyi pushed a commit to branch next
in repository https://gitbox.apache.org/repos/asf/incubator-echarts.git
commit 5e3ed2b2beadce1365aaac83cf75f49d4a8c3672
Author: pissang <bm...@gmail.com>
AuthorDate: Tue Oct 20 18:39:03 2020 +0800
optimize default position of grid to avoid overlap with dataZoom
---
src/chart/line/LineSeries.ts | 2 +-
src/coord/cartesian/Grid.ts | 17 ++++++++++++++---
src/coord/cartesian/GridModel.ts | 18 ++++++++++++++----
src/model/globalDefault.ts | 1 -
4 files changed, 29 insertions(+), 9 deletions(-)
diff --git a/src/chart/line/LineSeries.ts b/src/chart/line/LineSeries.ts
index 44ed861..8b29919 100644
--- a/src/chart/line/LineSeries.ts
+++ b/src/chart/line/LineSeries.ts
@@ -136,7 +136,7 @@ class LineSeriesModel extends SeriesModel<LineSeriesOption> {
static defaultOption: LineSeriesOption = {
zlevel: 0,
- z: 2,
+ z: 3,
coordinateSystem: 'cartesian2d',
legendHoverLink: true,
diff --git a/src/coord/cartesian/Grid.ts b/src/coord/cartesian/Grid.ts
index 96801c8..a37bc07 100644
--- a/src/coord/cartesian/Grid.ts
+++ b/src/coord/cartesian/Grid.ts
@@ -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);
diff --git a/src/coord/cartesian/GridModel.ts b/src/coord/cartesian/GridModel.ts
index 7ca3682..e0d150d 100644
--- a/src/coord/cartesian/GridModel.ts
+++ b/src/coord/cartesian/GridModel.ts
@@ -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,
diff --git a/src/model/globalDefault.ts b/src/model/globalDefault.ts
index 6e67a12..289bcc7 100644
--- a/src/model/globalDefault.ts
+++ b/src/model/globalDefault.ts
@@ -76,7 +76,6 @@ export default {
stateAnimation: {
duration: 300,
easing: 'cubicOut'
- // additive: true
},
animation: 'auto',
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org