You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@echarts.apache.org by wa...@apache.org on 2024/07/02 04:15:05 UTC
(echarts) branch fix/k-states created (now e6dab043c)
This is an automated email from the ASF dual-hosted git repository.
wangzx pushed a change to branch fix/k-states
in repository https://gitbox.apache.org/repos/asf/echarts.git
at e6dab043c fix(candlestick): add back missing support for non-normal states since v5.0.0
This branch includes the following new commits:
new e6dab043c fix(candlestick): add back missing support for non-normal states since v5.0.0
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org
(echarts) 01/01: fix(candlestick): add back missing support for non-normal states since v5.0.0
Posted by wa...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
wangzx pushed a commit to branch fix/k-states
in repository https://gitbox.apache.org/repos/asf/echarts.git
commit e6dab043c24dba2e7c7eaba2d5529a3ea861c4da
Author: plainheart <yh...@all-my-life.cn>
AuthorDate: Tue Jul 2 12:12:25 2024 +0800
fix(candlestick): add back missing support for non-normal states since v5.0.0
---
src/chart/candlestick/CandlestickView.ts | 23 ++++++++++----
src/chart/candlestick/candlestickVisual.ts | 31 +++++++++---------
test/candlestick-case.html | 51 +++++++++++++++++++++++++++++-
test/runTest/actions/__meta__.json | 2 +-
test/runTest/actions/candlestick-case.json | 2 +-
5 files changed, 84 insertions(+), 25 deletions(-)
diff --git a/src/chart/candlestick/CandlestickView.ts b/src/chart/candlestick/CandlestickView.ts
index 3d05e81c7..728291424 100644
--- a/src/chart/candlestick/CandlestickView.ts
+++ b/src/chart/candlestick/CandlestickView.ts
@@ -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';
@@ -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;
@@ -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) {
@@ -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
diff --git a/src/chart/candlestick/candlestickVisual.ts b/src/chart/candlestick/candlestickVisual.ts
index 8882d6333..a665ea3b6 100644
--- a/src/chart/candlestick/candlestickVisual.ts
+++ b/src/chart/candlestick/candlestickVisual.ts
@@ -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',
@@ -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;
diff --git a/test/candlestick-case.html b/test/candlestick-case.html
index 2e5a33f74..6a408a644 100644
--- a/test/candlestick-case.html
+++ b/test/candlestick-case.html
@@ -38,7 +38,7 @@ under the License.
<div id="main0"></div>
-
+ <div id="main1"></div>
@@ -363,6 +363,55 @@ under the License.
});
</script>
+ <script>
+ require([
+ 'echarts',
+ ], function (echarts) {
+ var option = {
+ xAxis: {
+ data: ['2017-10-24', '2017-10-25', '2017-10-26', '2017-10-27']
+ },
+ yAxis: {},
+ series: [{
+ type: 'candlestick',
+ data: [
+ [20, 34, 10, 38],
+ [40, 35, 30, 50],
+ [31, 38, 28, 44],
+ [38, 15, 5, 42]
+ ],
+ emphasis: {
+ disabled: false,
+ focus: 'self',
+ itemStyle: {
+ color: 'purple',
+ borderColor: 'cyan',
+
+ color0: 'blue',
+ borderColor0: 'brown'
+ }
+ },
+ blur: {
+ itemStyle: {
+ color: 'grey',
+ borderColor: 'pink',
+
+ color0: 'gray',
+ borderColor0: 'orange',
+
+ opacity: 1
+ }
+ }
+ }]
+ };
+ var chart = testHelper.create(echarts, 'main1', {
+ title: [
+ 'Emphasis and other states should be working'
+ ],
+ option: option
+ });
+ });
+ </script>
</body>
</html>
diff --git a/test/runTest/actions/__meta__.json b/test/runTest/actions/__meta__.json
index 26eac6dd2..998f79077 100644
--- a/test/runTest/actions/__meta__.json
+++ b/test/runTest/actions/__meta__.json
@@ -45,7 +45,7 @@
"calendar-heatmap": 1,
"calendar-month": 1,
"candlestick": 2,
- "candlestick-case": 1,
+ "candlestick-case": 2,
"candlestick-empty": 1,
"candlestick-large": 4,
"candlestick-large2": 1,
diff --git a/test/runTest/actions/candlestick-case.json b/test/runTest/actions/candlestick-case.json
index bc02692b4..0b07b405e 100644
--- a/test/runTest/actions/candlestick-case.json
+++ b/test/runTest/actions/candlestick-case.json
@@ -1 +1 @@
-[{"name":"Action 1","ops":[{"type":"mousedown","time":300,"x":50,"y":77},{"type":"mouseup","time":423,"x":50,"y":77},{"time":424,"delay":400,"type":"screenshot-auto"}],"scrollY":0,"scrollX":0,"timestamp":1626405373145}]
\ No newline at end of file
+[{"name":"Action 1","ops":[{"type":"mousedown","time":300,"x":50,"y":77},{"type":"mouseup","time":423,"x":50,"y":77},{"time":424,"delay":400,"type":"screenshot-auto"}],"scrollY":0,"scrollX":0,"timestamp":1626405373145},{"name":"Action 2","ops":[{"type":"mousemove","time":303,"x":145,"y":215},{"type":"mousemove","time":505,"x":169,"y":336},{"type":"mousemove","time":722,"x":170,"y":369},{"type":"screenshot","time":1492},{"type":"mousemove","time":1769,"x":199,"y":364},{"type":"mousemove", [...]
\ No newline at end of file
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org