This is an automated email from the ASF dual-hosted git repository. ovilia pushed a commit to branch feat/k in repository https://gitbox.apache.org/repos/asf/echarts.git
commit 0ac383d51021c7be549a5a3e0b18bb13f74c4ec0 Author: Ovilia <[email protected]> AuthorDate: Thu Jul 25 19:30:49 2024 +0800 test(marker): update test case --- test/markPoint-stock.html | 95 ++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 82 insertions(+), 13 deletions(-) diff --git a/test/markPoint-stock.html b/test/markPoint-stock.html index e831e3f6a..c21cc59f8 100644 --- a/test/markPoint-stock.html +++ b/test/markPoint-stock.html @@ -52,15 +52,25 @@ under the License. ], function (echarts) { var option; + const lastClose = 100; const data = []; let date = new Date('2024-07-11 9:30:00'); const endDate = new Date('2024-07-11 15:00:00'); - let value = 120; + let value = lastClose; + let max = -Number.MAX_VALUE; + let min = Number.MAX_VALUE; for (; date <= endDate;) { if (date < new Date('2024-07-11 11:30:00').getTime() || date > new Date('2024-07-11 13:00:00').getTime() ) { - value = value + Math.round((Math.random() - 0.5) * 20); + value = Math.max(0, value + Math.round((Math.random() - 0.5) * 20)); + } + + if (value > max) { + max = value; + } + if (value < min) { + min = value; } data.push([ date, @@ -79,7 +89,7 @@ under the License. }, yAxis: { axisLabel: { - // show: false, + show: false, }, min: 'dataMin', max: 'dataMax' @@ -89,32 +99,91 @@ under the License. data, showSymbol: false, markPoint: { + symbol: 'circle', + symbolSize: 0, + label: { + position: 'top', + distance: 0, + padding: 5, + textBorderColor: '#fff', + textBorderWidth: 2 + }, data: [{ type: 'min', x: 0, y: 0, - relativeTo: 'coordinate' + relativeTo: 'coordinate', + label: { + align: 'left', + verticalAlign: 'top', + color: min > lastClose ? 'red' : 'green', + } }, { type: 'max', x: 0, y: '100%', - relativeTo: 'coordinate' + relativeTo: 'coordinate', + label: { + align: 'left', + verticalAlign: 'bottom', + color: max > lastClose ? 'red' : 'green', + } + }, { + type: 'middle', + x: 0, + y: '50%', + relativeTo: 'coordinate', + label: { + align: 'left', + verticalAlign: 'middle', + formatter: () => { + return (max + min) / 2; + }, + color: (max + min) / 2 > lastClose ? 'red' : 'green', + } }, { type: 'min', x: '100%', y: 0, name: 'abcd', - relativeTo: 'coordinate' + relativeTo: 'coordinate', + label: { + align: 'right', + verticalAlign: 'top', + formatter: () => { + // Percentage of min + return ((min - lastClose) / lastClose * 100).toFixed(2) + '%'; + }, + color: min > lastClose ? 'red' : 'green', + } }, { type: 'max', - // x: '100%', - // y: '100%', - // relativeTo: 'coordinate' + x: '100%', + y: '100%', + relativeTo: 'coordinate', + label: { + align: 'right', + verticalAlign: 'bottom', + formatter: () => { + // Percentage of max + return ((max - lastClose) / lastClose * 100).toFixed(2) + '%'; + }, + color: max > lastClose ? 'red' : 'green', + } + }, { + name: 'middlePercentage', + x: '100%', + y: '50%', + relativeTo: 'coordinate', + label: { + align: 'right', + verticalAlign: 'middle', + formatter: () => { + return (((max + min) / 2 - lastClose) / lastClose * 100).toFixed(2) + '%'; + }, + color: (max + min) / 2 > lastClose ? 'red' : 'green', + } }], - // label: { - // show: true, - // formatter: 'x: {c}' - // } } } }; --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
