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

Merge master into next #20252

Merged
merged 33 commits into from
Aug 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
769bfef
fix(pie): Missing pie chart label display. close #20070
Jun 25, 2024
e6dab04
fix(candlestick): add back missing support for non-normal states sinc…
plainheart Jul 2, 2024
e4061f6
fix(candlestick): disable emphasis state by default for forward compa…
plainheart Jul 2, 2024
a4d803f
feature(axis): add feature to remove SplitLine on specified tick
adaelixir Jul 4, 2024
35fa0cb
chore: enable prompt to use typescript from workspace
plainheart Jul 8, 2024
1166f2d
fix(legend): fix legend action is not isolated from other legend comp…
plainheart Jul 8, 2024
7564282
test(legend): add a test case for legend action
plainheart Jul 9, 2024
403dce2
fix(pie): fix some labels may not show #20074
Jul 9, 2024
cc26ef3
fix(legend): fix legend item is selected but corresponding series may…
plainheart Jul 11, 2024
c7f672f
fix(legend): remove unused import
plainheart Jul 11, 2024
c329192
Merge pull request #20123 from apache/workspace-ts-prompt
Ovilia Jul 11, 2024
33249dc
chore(workflow): fix pr-preview workflow
plainheart Jul 11, 2024
6ce6ba3
fix(legend): remove duplicated type of legend select method name
plainheart Jul 11, 2024
13fe1d9
fix(legend): return allSelectedMap rather than selectedMap
plainheart Jul 11, 2024
4d3cb2c
Merge pull request #20144 from apache/workflow/pr-preview
Ovilia Jul 15, 2024
86db174
perf(line): prebind context of `_changePolyState` function to current…
plainheart Jul 15, 2024
89a15af
fix(candelstick): still enable emphasis state by default
plainheart Jul 15, 2024
89cfb36
Merge pull request #20129 from apache/fix/legend-action-isolation
linghaoSu Jul 16, 2024
c9ac641
Merge pull request #20105 from apache/fix/k-states
plainheart Jul 17, 2024
65f6255
Merge pull request #20161 from apache/perf/line-memory-cost
plainheart Jul 18, 2024
8e968f4
Merge pull request #20114 from adaelixir/feature-#20110
Ovilia Jul 18, 2024
7a06637
Merge pull request #20074 from liuyunzidian/fix-20070
Ovilia Jul 18, 2024
72e3f80
chore(deps-dev): bump socket.io-parser in /test/runTest
dependabot[bot] Jul 23, 2024
11c5a12
Merge pull request #20187 from apache/dependabot/npm_and_yarn/test/ru…
Ovilia Jul 23, 2024
5fb9e9d
fix(axis): ticks overflowing grid area with dataZoom #20185
Ovilia Jul 24, 2024
eeaf52e
Merge pull request #20194 from apache/fix/customValues
plainheart Jul 24, 2024
ce500cf
feature(treemap): add custom cursor properties for treemap (#20113)
adaelixir Jul 29, 2024
aeb078e
feat(aria): allows excluding data in aria-label
semla Aug 1, 2024
b1a2374
refactor(aria): rename property to exclude
semla Aug 2, 2024
4379789
Merge pull request #20218 from semla/aria-exclude-columns
Ovilia Aug 5, 2024
7c7a3ed
feat(i18n): add Swedish(SV) translation (#20227)
NajamShehzad Aug 6, 2024
3bd3c7c
fix(time): bar bandWidth with inversed time axis #20068
Ovilia Aug 12, 2024
7955a46
Merge pull request #20246 from apache/time-inverse
plainheart Aug 12, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/pr-preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,12 @@ jobs:
workflow: ${{ github.event.workflow.id }}
run_id: ${{ github.event.workflow_run.id }}
name: pr_preview
path: pr-dist
if_no_artifact_found: fail

- name: Output PR metadata
id: pr-metadata
working-directory: pr-dist
run: |
echo "NUMBER=$(cat pr_number)" >> $GITHUB_OUTPUT
echo "COMMIT_SHA=$(cat pr_commit_sha)" >> $GITHUB_OUTPUT
Expand All @@ -59,6 +61,7 @@ jobs:
env:
PR_NUMBER: ${{ steps.pr-metadata.outputs.NUMBER }}
SURGE_TOKEN: ${{ secrets.SURGE_TOKEN }}
working-directory: pr-dist
run: |
export SURGE_DOMAIN=https://echarts-pr-$PR_NUMBER.surge.sh
npx surge --project ./package --domain $SURGE_DOMAIN --token $SURGE_TOKEN
Expand Down
5 changes: 3 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"typescript.tsdk": "./node_modules/typescript/lib"
}
"typescript.tsdk": "./node_modules/typescript/lib",
"typescript.enablePromptUseWorkspaceTsdk": true
}
1 change: 0 additions & 1 deletion src/chart/candlestick/CandlestickSeries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ class CandlestickSeriesModel extends SeriesModel<CandlestickSeriesOption> {
},

emphasis: {
scale: true,
itemStyle: {
borderWidth: 2
}
Expand Down
23 changes: 17 additions & 6 deletions src/chart/candlestick/CandlestickView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import * as zrUtil from 'zrender/src/core/util';
import ChartView from '../../view/Chart';
import * as graphic from '../../util/graphic';
import { setStatesStylesFromModel } from '../../util/states';
import { setStatesStylesFromModel, toggleHoverEmphasis } from '../../util/states';
import Path, { PathProps } from 'zrender/src/graphic/Path';
import {createClipPath} from '../helper/createClipPathFromCoordSys';
import CandlestickSeriesModel, { CandlestickDataItemOption } from './CandlestickSeries';
Expand All @@ -33,6 +33,7 @@ import { CoordinateSystemClipArea } from '../../coord/CoordinateSystem';
import Model from '../../model/Model';
import { saveOldStyle } from '../../animation/basicTransition';
import Element from 'zrender/src/Element';
import { getBorderColor, getColor } from './candlestickVisual';

const SKIP_PROPS = ['color', 'borderColor'] as const;

Expand Down Expand Up @@ -294,6 +295,19 @@ function setBoxCommon(el: NormalBoxPath, data: SeriesData, dataIndex: number, is
el.__simpleBox = isSimpleBox;

setStatesStylesFromModel(el, itemModel);

const sign = data.getItemLayout(dataIndex).sign;
zrUtil.each(el.states, (state, stateName) => {
const stateModel = itemModel.getModel(stateName as any);
const color = getColor(sign, stateModel);
const borderColor = getBorderColor(sign, stateModel) || color;
const stateStyle = state.style || (state.style = {});
color && (stateStyle.fill = color);
borderColor && (stateStyle.stroke = borderColor);
});

const emphasisModel = itemModel.getModel('emphasis');
toggleHoverEmphasis(el, emphasisModel.get('focus'), emphasisModel.get('blurScope'), emphasisModel.get('disabled'));
}

function transInit(points: number[][], itemLayout: CandlestickItemLayout) {
Expand Down Expand Up @@ -391,12 +405,9 @@ function createLarge(

function setLargeStyle(sign: number, el: LargeBoxPath, seriesModel: CandlestickSeriesModel, data: SeriesData) {
// TODO put in visual?
let borderColor = seriesModel.get(['itemStyle', sign > 0 ? 'borderColor' : 'borderColor0'])
const borderColor = getBorderColor(sign, seriesModel)
// Use color for border color by default.
|| seriesModel.get(['itemStyle', sign > 0 ? 'color' : 'color0']);
if (sign === 0) {
borderColor = seriesModel.get(['itemStyle', 'borderColorDoji']);
}
|| getColor(sign, seriesModel);

// Color must be excluded.
// Because symbol provide setColor individually to set fill and stroke
Expand Down
31 changes: 15 additions & 16 deletions src/chart/candlestick/candlestickVisual.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,21 @@ const dojiBorderColorQuery = ['itemStyle', 'borderColorDoji'] as const;
const positiveColorQuery = ['itemStyle', 'color'] as const;
const negativeColorQuery = ['itemStyle', 'color0'] as const;

export function getColor(sign: number, model: Model<Pick<CandlestickDataItemOption, 'itemStyle'>>) {
return model.get(
sign > 0 ? positiveColorQuery : negativeColorQuery
);
}

export function getBorderColor(sign: number, model: Model<Pick<CandlestickDataItemOption, 'itemStyle'>>) {
return model.get(
sign === 0 ? dojiBorderColorQuery
: sign > 0
? positiveBorderColorQuery
: negativeBorderColorQuery
);
}

const candlestickVisual: StageHandler = {

seriesType: 'candlestick',
Expand All @@ -39,22 +54,6 @@ const candlestickVisual: StageHandler = {
performRawSeries: true,

reset: function (seriesModel: CandlestickSeriesModel, ecModel) {

function getColor(sign: number, model: Model<Pick<CandlestickDataItemOption, 'itemStyle'>>) {
return model.get(
sign > 0 ? positiveColorQuery : negativeColorQuery
);
}

function getBorderColor(sign: number, model: Model<Pick<CandlestickDataItemOption, 'itemStyle'>>) {
return model.get(
sign === 0 ? dojiBorderColorQuery
: sign > 0
? positiveBorderColorQuery
: negativeBorderColorQuery
);
}

// Only visible series has each data be visual encoded
if (ecModel.isSeriesFiltered(seriesModel)) {
return;
Expand Down
6 changes: 3 additions & 3 deletions src/chart/line/LineView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -624,6 +624,8 @@ class LineView extends ChartView {

this._symbolDraw = symbolDraw;
this._lineGroup = lineGroup;

this._changePolyState = zrUtil.bind(this._changePolyState, this);
}

render(seriesModel: LineSeriesModel, ecModel: GlobalModel, api: ExtensionAPI) {
Expand Down Expand Up @@ -885,9 +887,7 @@ class LineView extends ChartView {
toggleHoverEmphasis(polygon, focus, blurScope, emphasisDisabled);
}

const changePolyState = (toState: DisplayState) => {
this._changePolyState(toState);
};
const changePolyState = this._changePolyState;

data.eachItemGraphicEl(function (el) {
// Switch polyline / polygon state if element changed its state.
Expand Down
2 changes: 1 addition & 1 deletion src/chart/pie/labelLayout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ function adjustSingleSide(
const rA = r + item.len;
const rA2 = rA * rA;
// Use ellipse implicit function to calculate x
const dx = Math.sqrt((1 - Math.abs(dy * dy / rB2)) * rA2);
const dx = Math.sqrt(Math.abs((1 - dy * dy / rB2) * rA2));
const newX = cx + (dx + item.len2) * dir;
const deltaX = newX - item.label.x;
const newTargetWidth = item.targetTextWidth - deltaX * dir;
Expand Down
4 changes: 3 additions & 1 deletion src/chart/treemap/TreemapSeries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,9 @@ export interface TreemapSeriesNodeItemOption extends TreemapSeriesVisualOption,

color?: ColorString[] | 'none'

decal?: DecalObject[] | 'none'
decal?: DecalObject[] | 'none',

cursor?: string
}

export interface TreemapSeriesOption
Expand Down
3 changes: 3 additions & 0 deletions src/chart/treemap/TreemapView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -877,6 +877,9 @@ function renderNode(
// Only for enabling highlight/downplay.
data.setItemGraphicEl(thisNode.dataIndex, group);

const cursorStyle = nodeModel.getShallow('cursor');
cursorStyle && content.attr('cursor', cursorStyle);

enableHoverFocus(group, focusOrIndices, blurScope);
}

Expand Down
11 changes: 9 additions & 2 deletions src/component/axis/CartesianAxisView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@ const axisElementBuilders: Record<typeof selfBuilderAttrs[number], AxisElementBu
const splitLineModel = axisModel.getModel('splitLine');
const lineStyleModel = splitLineModel.getModel('lineStyle');
let lineColors = lineStyleModel.get('color');
const showMinLine = splitLineModel.get('showMinLine') !== false;
const showMaxLine = splitLineModel.get('showMaxLine') !== false;

lineColors = zrUtil.isArray(lineColors) ? lineColors : [lineColors];

Expand All @@ -142,6 +144,12 @@ const axisElementBuilders: Record<typeof selfBuilderAttrs[number], AxisElementBu
for (let i = 0; i < ticksCoords.length; i++) {
const tickCoord = axis.toGlobalCoord(ticksCoords[i].coord);

if ((i === 0 && !showMinLine) || (i === ticksCoords.length - 1 && !showMaxLine)) {
continue;
}

const tickValue = ticksCoords[i].tickValue;

if (isHorizontal) {
p1[0] = tickCoord;
p1[1] = gridRect.y;
Expand All @@ -156,9 +164,8 @@ const axisElementBuilders: Record<typeof selfBuilderAttrs[number], AxisElementBu
}

const colorIndex = (lineCount++) % lineColors.length;
const tickValue = ticksCoords[i].tickValue;
const line = new graphic.Line({
anid: tickValue != null ? 'line_' + ticksCoords[i].tickValue : null,
anid: tickValue != null ? 'line_' + tickValue : null,
autoBatch: true,
shape: {
x1: p1[0],
Expand Down
3 changes: 2 additions & 1 deletion src/component/legend/LegendView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,8 @@ class LegendView extends ComponentView {
},
onclick() {
api.dispatchAction({
type: type === 'all' ? 'legendAllSelect' : 'legendInverseSelect'
type: type === 'all' ? 'legendAllSelect' : 'legendInverseSelect',
legendId: legendModel.id
});
}
});
Expand Down
96 changes: 59 additions & 37 deletions src/component/legend/legendAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,59 +17,81 @@
* under the License.
*/

// @ts-nocheck
import {curry, each, hasOwn} from 'zrender/src/core/util';
import { EChartsExtensionInstallRegisters } from '../../extension';
import { Payload } from '../../util/types';
import type GlobalModel from '../../model/Global';
import type LegendModel from './LegendModel';

import {curry, each} from 'zrender/src/core/util';
type LegendSelectMethodNames = 'select' | 'unSelect' | 'toggleSelected' | 'allSelect' | 'inverseSelect';

function legendSelectActionHandler(methodName, payload, ecModel) {
const selectedMap = {};
const isToggleSelect = methodName === 'toggleSelected';
let isSelected;
// Update all legend components
ecModel.eachComponent('legend', function (legendModel) {
if (isToggleSelect && isSelected != null) {
// Force other legend has same selected status
// Or the first is toggled to true and other are toggled to false
// In the case one legend has some item unSelected in option. And if other legend
// doesn't has the item, they will assume it is selected.
legendModel[isSelected ? 'select' : 'unSelect'](payload.name);
}
else if (methodName === 'allSelect' || methodName === 'inverseSelect') {
function legendSelectActionHandler(methodName: LegendSelectMethodNames, payload: Payload, ecModel: GlobalModel) {
const isAllSelect = methodName === 'allSelect' || methodName === 'inverseSelect';
const selectedMap: Record<string, boolean> = {};

const actionLegendIndices: number[] = [];
ecModel.eachComponent({ mainType: 'legend', query: payload }, function (legendModel: LegendModel) {
if (isAllSelect) {
legendModel[methodName]();
}
else {
legendModel[methodName](payload.name);
isSelected = legendModel.isSelected(payload.name);
}
const legendData = legendModel.getData();
each(legendData, function (model) {
const name = model.get('name');
// Wrap element
if (name === '\n' || name === '') {
return;
}
const isItemSelected = legendModel.isSelected(name);
if (selectedMap.hasOwnProperty(name)) {
// Unselected if any legend is unselected
selectedMap[name] = selectedMap[name] && isItemSelected;
}
else {
selectedMap[name] = isItemSelected;
}

makeSelectedMap(legendModel, selectedMap);

actionLegendIndices.push(legendModel.componentIndex);
});

const allSelectedMap: Record<string, boolean> = {};

// make selectedMap from all legend components
ecModel.eachComponent('legend', function (legendModel: LegendModel) {
each(selectedMap, function (isSelected, name) {
// Force other legend has same selected status
// Or the first is toggled to true and other are toggled to false
// In the case one legend has some item unSelected in option. And if other legend
// doesn't has the item, they will assume it is selected.
legendModel[isSelected ? 'select' : 'unSelect'](name);
});

makeSelectedMap(legendModel, allSelectedMap);
});

// Return the event explicitly
return (methodName === 'allSelect' || methodName === 'inverseSelect')
return isAllSelect
? {
selected: selectedMap
selected: allSelectedMap,
// return legendIndex array to tell the developers which legends are allSelect / inverseSelect
legendIndex: actionLegendIndices
}
: {
name: payload.name,
selected: selectedMap
selected: allSelectedMap
};
}

export function installLegendAction(registers) {
function makeSelectedMap(legendModel: LegendModel, out?: Record<string, boolean>) {
const selectedMap: Record<string, boolean> = out || {};
each(legendModel.getData(), function (model) {
const name = model.get('name');
// Wrap element
if (name === '\n' || name === '') {
return;
}
const isItemSelected = legendModel.isSelected(name);
if (hasOwn(selectedMap, name)) {
// Unselected if any legend is unselected
selectedMap[name] = selectedMap[name] && isItemSelected;
}
else {
selectedMap[name] = isItemSelected;
}
});
return selectedMap;
}

export function installLegendAction(registers: EChartsExtensionInstallRegisters) {
/**
* @event legendToggleSelect
* @type {Object}
Expand Down Expand Up @@ -113,4 +135,4 @@ export function installLegendAction(registers) {
'legendUnSelect', 'legendunselected',
curry(legendSelectActionHandler, 'unSelect')
);
}
}
4 changes: 2 additions & 2 deletions src/coord/Axis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ function fixOnBandTicksCoords(
let diffSize;
if (ticksLen === 1) {
ticksCoords[0].coord = axisExtent[0];
last = ticksCoords[1] = {coord: axisExtent[1]};
last = ticksCoords[1] = {coord: axisExtent[1], tickValue: ticksCoords[0].tickValue};
}
else {
const crossLen = ticksCoords[ticksLen - 1].tickValue - ticksCoords[0].tickValue;
Expand All @@ -315,7 +315,7 @@ function fixOnBandTicksCoords(
const dataExtent = axis.scale.getExtent();
diffSize = 1 + dataExtent[1] - ticksCoords[ticksLen - 1].tickValue;

last = {coord: ticksCoords[ticksLen - 1].coord + shift * diffSize};
last = {coord: ticksCoords[ticksLen - 1].coord + shift * diffSize, tickValue: dataExtent[1] + 1};

ticksCoords.push(last);
}
Expand Down
6 changes: 5 additions & 1 deletion src/coord/axisCommonTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,11 @@ interface MinorTickOption {

interface SplitLineOption {
show?: boolean,
interval?: 'auto' | number | ((index:number, value: string) => boolean)
interval?: 'auto' | number | ((index:number, value: string) => boolean),
// true | false
showMinLine?: boolean,
// true | false
showMaxLine?: boolean,
// colors will display in turn
lineStyle?: LineStyleOption<ZRColor | ZRColor[]>
}
Expand Down
2 changes: 2 additions & 0 deletions src/coord/axisDefault.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ const defaultOption: AxisBaseOption = {
},
splitLine: {
show: true,
showMinLine: true,
showMaxLine: true,
lineStyle: {
color: ['#E0E6F1'],
width: 1,
Expand Down
Loading