Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE] [5.0] Improve style of dataZoom, visualMap, timeline components. Bug fixes from next branch #13008

Merged
merged 19 commits into from Jul 24, 2020
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
30c00f4
feat(dataZoom): optimize style. add borderRadius, selectedDataBackground
pissang Jul 20, 2020
aea2fbf
feat(visualMap): optimize visualMap style. add several styling config
pissang Jul 20, 2020
9a665c5
feat(visualMap): optimize indicator and handle in symbolSize visual m…
pissang Jul 21, 2020
3ac3175
fix(lines): fix unexpected fill in polyline
pissang Jul 21, 2020
41ba157
fix(export): add back echarts.format.getTextRect
pissang Jul 21, 2020
8fea284
fix(label): support legacy style color: 'auto' for color: 'inherit' u…
pissang Jul 21, 2020
6f5d9d7
fix(symbol): fix image symbol not display bug
pissang Jul 21, 2020
6fca352
fix(axisPointer): not use align: 'center' because it's already been c…
pissang Jul 21, 2020
a7c0d8c
feat(bar): improve gaps between bar. #12935
pissang Jul 21, 2020
a7f2c16
fix(state): not blur others when highlighting with axisPointer
pissang Jul 21, 2020
3ddf62a
fix: add back hover layer.
pissang Jul 22, 2020
26ca0b5
fix(treemap): truncate text when exceeds height
pissang Jul 22, 2020
459a9d8
feat(timeline): optimize timeline style. add progress config
pissang Jul 22, 2020
45a7ef3
timeline: progress logic tweak.
pissang Jul 22, 2020
1dda43c
fix(pie): fix wrong label x,y in select state when position is inside
pissang Jul 23, 2020
7a09ecc
refact(state): useHoverLayer all replaced with states.emphasis.hoverL…
pissang Jul 23, 2020
33a8ec7
fix(legend): fix legend color with visual encoded on style.stroke
pissang Jul 23, 2020
74aefce
feat(timeline): improve icon and label color.
pissang Jul 23, 2020
1b5efea
fix(timeline): fix wrong progress status on label when several labels…
pissang Jul 24, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 0 additions & 2 deletions src/ExtensionAPI.ts
Expand Up @@ -55,8 +55,6 @@ abstract class ExtensionAPI {

// Implemented in echarts.js
abstract getCoordinateSystems(): CoordinateSystemMaster[];

// Implemented in echarts.js
abstract getComponentByElement(el: Element): ComponentModel;
}

Expand Down
1 change: 0 additions & 1 deletion src/chart/bar/BarView.ts
Expand Up @@ -626,7 +626,6 @@ const elementCreator: {
shape: extend({}, layout),
z2: 1
});
// rect.autoBatch = true;

rect.name = 'item';

Expand Down
14 changes: 13 additions & 1 deletion src/chart/bar/PictorialBarView.ts
Expand Up @@ -38,6 +38,7 @@ import type Element from 'zrender/src/Element';
import { getDefaultLabel } from '../helper/labelHelper';
import { PathProps, PathStyleProps } from 'zrender/src/graphic/Path';
import { setLabelStyle, getLabelStatesModels } from '../../label/labelStyle';
import ZRImage from 'zrender/src/graphic/Image';


const BAR_BORDER_WIDTH_QUERY = ['itemStyle', 'borderWidth'] as const;
Expand Down Expand Up @@ -888,7 +889,18 @@ function updateCommon(
const blurScope = emphasisModel.get('blurScope');

eachPath(bar, function (path) {
path.useStyle(symbolMeta.style);
if (path instanceof ZRImage) {
const pathStyle = path.style;
path.useStyle(zrUtil.extend({
// TODO other properties like dx, dy ?
image: pathStyle.image,
x: pathStyle.x, y: pathStyle.y,
width: pathStyle.width, height: pathStyle.height
}, symbolMeta.style));
}
else {
path.useStyle(symbolMeta.style);
}

const emphasisState = path.ensureState('emphasis');
emphasisState.style = emphasisStyle;
Expand Down
2 changes: 1 addition & 1 deletion src/chart/custom.ts
Expand Up @@ -500,7 +500,7 @@ class CustomSeriesView extends ChartView {
function setIncrementalAndHoverLayer(el: Displayable) {
if (!el.isGroup) {
el.incremental = true;
el.useHoverLayer = true;
el.ensureState('emphasis').hoverLayer = true;
}
}
for (let idx = params.start; idx < params.end; idx++) {
Expand Down
4 changes: 3 additions & 1 deletion src/chart/gauge/GaugeView.ts
Expand Up @@ -264,7 +264,9 @@ class GaugeView extends ChartView {
y: unitY * (r - splitLineLen - distance) + cy,
verticalAlign: unitY < -0.4 ? 'top' : (unitY > 0.4 ? 'bottom' : 'middle'),
align: unitX < -0.4 ? 'left' : (unitX > 0.4 ? 'right' : 'center')
}, {inheritColor: autoColor}),
}, {
inheritColor: autoColor
}),
silent: true
}));
}
Expand Down
2 changes: 1 addition & 1 deletion src/chart/heatmap/HeatmapView.ts
Expand Up @@ -281,7 +281,7 @@ class HeatmapView extends ChartView {
// PENDING
if (incremental) {
// Rect must use hover layer if it's incremental.
rect.useHoverLayer = true;
rect.states.emphasis.hoverLayer = true;
}

group.add(rect);
Expand Down
3 changes: 2 additions & 1 deletion src/chart/helper/LineDraw.ts
Expand Up @@ -154,7 +154,8 @@ class LineDraw {
incrementalUpdate(taskParams: StageHandlerProgressParams, lineData: ListForLineDraw) {
function updateIncrementalAndHover(el: Displayable) {
if (!el.isGroup && !isEffectObject(el)) {
el.incremental = el.useHoverLayer = true;
el.incremental = true;
el.ensureState('emphasis').hoverLayer = true;
}
}

Expand Down
1 change: 1 addition & 0 deletions src/chart/helper/Polyline.ts
Expand Up @@ -68,6 +68,7 @@ class Polyline extends graphic.Group {
hoverLineStyle = itemModel.getModel(['emphasis', 'lineStyle']).getLineStyle();
}
line.useStyle(lineData.getItemVisual(idx, 'style'));
line.style.fill = null;
line.style.strokeNoScale = true;

const lineEmphasisState = line.ensureState('emphasis');
Expand Down
31 changes: 22 additions & 9 deletions src/chart/helper/Symbol.ts
Expand Up @@ -29,6 +29,7 @@ import { PathProps } from 'zrender/src/graphic/Path';
import { SymbolDrawSeriesScope, SymbolDrawItemModelOption } from './SymbolDraw';
import { extend } from 'zrender/src/core/util';
import { setLabelStyle, getLabelStatesModels } from '../../label/labelStyle';
import ZRImage from 'zrender/src/graphic/Image';

type ECSymbol = ReturnType<typeof createSymbol>;

Expand Down Expand Up @@ -260,18 +261,30 @@ class Symbol extends graphic.Group {

const symbolStyle = data.getItemVisual(idx, 'style');
const visualColor = symbolStyle.fill;
if (symbolPath.__isEmptyBrush) {
// fill and stroke will be swapped if it's empty.
// So we cloned a new style to avoid it affecting the original style in visual storage.
// TODO Better implementation. No empty logic!
symbolPath.useStyle(extend({}, symbolStyle));

if (symbolPath instanceof ZRImage) {
const pathStyle = symbolPath.style;
symbolPath.useStyle(extend({
// TODO other properties like x, y ?
image: pathStyle.image,
x: pathStyle.x, y: pathStyle.y,
width: pathStyle.width, height: pathStyle.height
}, symbolStyle));
}
else {
symbolPath.useStyle(symbolStyle);
}
symbolPath.setColor(visualColor, opts && opts.symbolInnerColor);
symbolPath.style.strokeNoScale = true;
if (symbolPath.__isEmptyBrush) {
// fill and stroke will be swapped if it's empty.
// So we cloned a new style to avoid it affecting the original style in visual storage.
// TODO Better implementation. No empty logic!
symbolPath.useStyle(extend({}, symbolStyle));
}
else {
symbolPath.useStyle(symbolStyle);
}
symbolPath.setColor(visualColor, opts && opts.symbolInnerColor);
symbolPath.style.strokeNoScale = true;

}
const liftZ = data.getItemVisual(idx, 'liftZ');
const z2Origin = this._z2;
if (liftZ != null) {
Expand Down
3 changes: 2 additions & 1 deletion src/chart/helper/SymbolDraw.ts
Expand Up @@ -256,7 +256,8 @@ class SymbolDraw {

function updateIncrementalAndHover(el: Displayable) {
if (!el.isGroup) {
el.incremental = el.useHoverLayer = true;
el.incremental = true;
el.ensureState('emphasis').hoverLayer = true;
}
}
for (let idx = taskParams.start; idx < taskParams.end; idx++) {
Expand Down
5 changes: 5 additions & 0 deletions src/chart/pie/labelLayout.ts
Expand Up @@ -388,6 +388,11 @@ export default function (
label.setStyle({
align: textAlign
});
const selectState = label.states.select;
if (selectState) {
selectState.x += label.x;
selectState.y += label.y;
}
}
sector.setTextConfig({
inside: isLabelInside
Expand Down
16 changes: 14 additions & 2 deletions src/chart/radar/RadarView.ts
Expand Up @@ -29,6 +29,7 @@ import { ColorString } from '../../util/types';
import GlobalModel from '../../model/Global';
import { VectorArray } from 'zrender/src/core/vector';
import { setLabelStyle, getLabelStatesModels } from '../../label/labelStyle';
import ZRImage from 'zrender/src/graphic/Image';

function normalizeSymbolSize(symbolSize: number | number[]) {
if (!zrUtil.isArray(symbolSize)) {
Expand Down Expand Up @@ -223,8 +224,19 @@ class RadarView extends ChartView {
const emphasisModel = itemModel.getModel('emphasis');
const itemHoverStyle = emphasisModel.getModel('itemStyle').getItemStyle();
symbolGroup.eachChild(function (symbolPath: RadarSymbol) {
symbolPath.useStyle(itemStyle);
symbolPath.setColor(color);
if (symbolPath instanceof ZRImage) {
const pathStyle = symbolPath.style;
symbolPath.useStyle(zrUtil.extend({
// TODO other properties like x, y ?
image: pathStyle.image,
x: pathStyle.x, y: pathStyle.y,
width: pathStyle.width, height: pathStyle.height
}, itemStyle));
}
else {
symbolPath.useStyle(itemStyle);
symbolPath.setColor(color);
}

const pathEmphasisState = symbolPath.ensureState('emphasis');
pathEmphasisState.style = zrUtil.clone(itemHoverStyle);
Expand Down
2 changes: 2 additions & 0 deletions src/chart/treemap/TreemapView.ts
Expand Up @@ -985,6 +985,8 @@ function renderNode(
const textStyle = textEl.style;
textStyle.truncateMinChar = 2;
textStyle.width = width;
textStyle.height = height;
textStyle.lineOverflow = 'truncate';

addDrillDownIcon(textStyle, upperLabelRect, thisLayout);
const textEmphasisState = textEl.getState('emphasis');
Expand Down
18 changes: 13 additions & 5 deletions src/component/axisPointer/axisTrigger.ts
Expand Up @@ -22,7 +22,7 @@ import * as modelHelper from './modelHelper';
import findPointFromSeries from './findPointFromSeries';
import GlobalModel from '../../model/Global';
import ExtensionAPI from '../../ExtensionAPI';
import { Dictionary, Payload, CommonAxisPointerOption } from '../../util/types';
import { Dictionary, Payload, CommonAxisPointerOption, HighlightPayload, DownplayPayload } from '../../util/types';
import AxisPointerModel, { AxisPointerOption } from './AxisPointerModel';
import { each, curry, bind, extend, Curry1 } from 'zrender/src/core/util';
import { ZRenderType } from 'zrender/src/zrender';
Expand Down Expand Up @@ -479,11 +479,19 @@ function dispatchHighDownActually(
});

toDownplay.length && api.dispatchAction({
type: 'downplay', escapeConnect: true, batch: toDownplay
});
type: 'downplay',
escapeConnect: true,
// Not blur others when highlight in axisPointer.
notBlur: true,
batch: toDownplay
} as DownplayPayload);
toHighlight.length && api.dispatchAction({
type: 'highlight', escapeConnect: true, batch: toHighlight
});
type: 'highlight',
escapeConnect: true,
// Not blur others when highlight in axisPointer.
notBlur: true,
batch: toHighlight
} as HighlightPayload);
}

function findInputAxisInfo(
Expand Down
1 change: 0 additions & 1 deletion src/component/axisPointer/viewHelper.ts
Expand Up @@ -126,7 +126,6 @@ export function buildLabelElOption(
text: text,
textFont: font,
fill: labelModel.getTextColor(),
align: 'center',
padding: paddings,
backgroundColor: bgColor as ColorString,
borderColor: labelModel.get('borderColor') || 'transparent',
Expand Down
60 changes: 48 additions & 12 deletions src/component/dataZoom/SliderZoomModel.ts
Expand Up @@ -53,11 +53,21 @@ export interface SliderDataZoomOption extends DataZoomOption, BoxLayoutOptionMix
*/
borderColor?: ZRColor

/**
* Border radius of the box.
*/
borderRadius?: number | number[]

dataBackground?: {
lineStyle?: LineStyleOption
areaStyle?: AreaStyleOption
}

selectedDataBackground?: {
lineStyle?: LineStyleOption
areaStyle?: AreaStyleOption
}

/**
* Color of selected area.
*/
Expand All @@ -71,7 +81,8 @@ export interface SliderDataZoomOption extends DataZoomOption, BoxLayoutOptionMix
handleIcon?: string

/**
* Percent of the slider height
* number: height of icon. width will be calculated according to the aspect of icon.
* string: percent of the slider height. width will be calculated according to the aspect of icon.
*/
handleSize?: string | number

Expand All @@ -88,6 +99,10 @@ export interface SliderDataZoomOption extends DataZoomOption, BoxLayoutOptionMix
zoomLock?: boolean

textStyle?: LabelOption

emphasis?: {
handleStyle?: ItemStyleOption
}
}


Expand All @@ -108,38 +123,59 @@ class SliderZoomModel extends DataZoomModel<SliderDataZoomOption> {
left: null, // Default align to grid rect.
bottom: null, // Default align to grid rect.

borderColor: '#d2dbee',
borderRadius: 3,

backgroundColor: 'rgba(47,69,84,0)', // Background of slider zoom component.

// dataBackgroundColor: '#ddd',
dataBackground: {
lineStyle: {
color: '#2f4554',
width: 0.5,
opacity: 0.3
color: '#d2dbee',
width: 0.5
},
areaStyle: {
color: 'rgba(47,69,84,0.3)',
opacity: 0.3
color: '#d2dbee',
opacity: 0.2
}
},
borderColor: '#ddd',

fillerColor: 'rgba(167,183,204,0.4)', // Color of selected area.
// handleColor: 'rgba(89,170,216,0.95)', // Color of handle.
// eslint-disable-next-line
handleIcon: 'M8.2,13.6V3.9H6.3v9.7H3.1v14.9h3.3v9.7h1.8v-9.7h3.3V13.6H8.2z M9.7,24.4H4.8v-1.4h4.9V24.4z M9.7,19.1H4.8v-1.4h4.9V19.1z',
selectedDataBackground: {
lineStyle: {
color: '#8fb0f7',
width: 0.5
},
areaStyle: {
color: '#8fb0f7',
opacity: 0.2
}
},


fillerColor: 'rgba(135,175,274,0.2)', // Color of selected area.
handleIcon: 'path://M-9.35,34.56V42m0-40V9.5m-2,0h4a2,2,0,0,1,2,2v21a2,2,0,0,1-2,2h-4a2,2,0,0,1-2-2v-21A2,2,0,0,1-11.35,9.5Z',
// Percent of the slider height
handleSize: '100%',

handleStyle: {
color: '#a7b7cc'
color: '#fff',
borderColor: '#ACB8D1'
},

showDetail: true,
showDataShadow: 'auto', // Default auto decision.
realtime: true,
zoomLock: false, // Whether disable zoom.

textStyle: {
color: '#333'
},

emphasis: {
handleStyle: {
borderColor: '#8FB0F7',
borderWidth: 2
}
}
});
}
Expand Down