/
githubmirror
/
echarts
Обзор
Документация
Войти
/
githubmirror
/
echarts
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
test/markPoint-stock.html
207 строк
7 KB
Ovilia
fix(marker): overwrite value only if type is not defined
19 июн 2025, 13:50
19 июн 2025, 13:50
ca03ff8
Код
Авторство
О чём код?
<!DOCTYPE html> <!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> <html> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1" /> <script src="lib/simpleRequire.js"></script> <script src="lib/config.js"></script> <script src="lib/jquery.min.js"></script> <script src="lib/facePrint.js"></script> <script src="lib/testHelper.js"></script> <!-- <script src="ut/lib/canteen.js"></script> --> <link rel="stylesheet" href="lib/reset.css" /> </head> <body> <style> </style> <div id="main0"></div> <script> require([ 'echarts', // 'map/js/china', // './data/nutrients.json' ], 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 = 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 = Math.max(0, value + Math.round((Math.random() - 0.5) * 20)); } if (value > max) { max = value; } if (value < min) { min = value; } data.push([ date, value ]); date = new Date(date.getTime() + 1000 * 60); } option = { xAxis: { type: 'time', axisLabel: { showMinLabel: true, showMaxLabel: true, } }, yAxis: { axisLabel: { show: false, }, min: 'dataMin', max: 'dataMax' }, series: { type: 'line', data, showSymbol: false, markPoint: { silent: true, symbol: 'circle', symbolSize: 0, label: { position: 'top', distance: 0, padding: 5, textBorderColor: '#fff', textBorderWidth: 2 }, data: [{ type: 'min', x: 0, y: 0, relativeTo: 'coordinate', label: { align: 'left', verticalAlign: 'top', color: min > lastClose ? 'red' : 'green', } }, { type: 'max', x: 0, y: '100%', 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', 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', 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', } }], } } }; var chart = testHelper.create(echarts, 'main0', { title: [ 'Test Case Description of main0', '(Muliple lines and **emphasis** are supported in description)' ], option: option // height: 300, // buttons: [{text: 'btn-txt', onclick: function () {}}], // recordCanvas: true, }); }); </script> </body> </html>