/
githubmirror
/
echarts
Обзор
Документация
Войти
/
githubmirror
/
echarts
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
test/heatmap-gap-bug.html
185 строк
53 KB
plainheart
fix(heatmap): add 0.5px to avoid the gaps in Cartesian 2D coordinate system when dpr is not an integer.
22 янв 2022, 21:39
22 янв 2022, 21:39
a5ad5de
Код
Авторство
О чём код?
<!-- 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"> <script src="lib/simpleRequire.js"></script> <script src="lib/config.js"></script> <meta name="viewport" content="width=device-width, initial-scale=1" /> </head> <body> <style> html, body, #main { width: 100%; height: 100%; margin: 0; } html, body { height: 100%; background: #fffcf8; overflow: hidden; } #myChart { width: 800px; height: 300px; } #myLineChart { width: 800px; height: 150px; margin: 0 auto; } .chart-wrapper { width: 802px; height: 400px; overflow-x: hidden; overflow-y: auto; margin: 0 auto; } .chart-content { width: 820px; height: 580px; margin: 30px auto; padding: 30px; border: 1px solid #e6e6e6; box-shadow: 0 0 5px 0px rgb(185, 185, 185); border-radius: 2px; background: #fff; } .info-panel { text-align: center; color: #4c4c4c; } /*定义滚动条高宽及背景 高宽分别对应横竖滚动条的尺寸*/ ::-webkit-scrollbar { width: 8px; height: 8px; background-color: #F5F5F5; } /*定义滚动条轨道 内阴影+圆角*/ ::-webkit-scrollbar-track { -webkit-box-shadow: inset 0 0 2px rgba(0,0,0,0.3); border-radius: 4px; background-color: #F5F5F5; } /*定义滑块 内阴影+圆角*/ ::-webkit-scrollbar-thumb { border-radius: 4px; -webkit-box-shadow: inset 0 0 2px rgba(0,0,0,.3); background-color: rgb(187, 187, 187); } </style> <div class="chart-content"> <div class="chart-wrapper"> <div id="myChart" style="height: 260px;"></div> </div> </div> <script> // gap usually appears when dpr is not an integer Object.defineProperty(window, 'devicePixelRatio', { value: 2.5, writable: false }); require([ 'echarts' ], function (echarts) { var chart = echarts.init(document.getElementById('myChart')); const yAxis = { "type": "category", "data": [ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18 ] }; const data2 = [[0,0,0.5],[1,0,0.548841875],[2,0,0.59144],[3,0,0.623388125],[4,0,0.64208],[5,0,0.646484375],[6,0,0.6369199999999999],[7,0,0.614830625],[8,0,0.58256],[9,0,0.543126875],[1 … [Строка слишком длинная. Вы можете скачать файл] let d = []; for (let i = 0; i < data2.length; i++) { if (data2[i][0] < 2) { d.push(data2[i]); } } chart.setOption({ grid: { left: 30, top: 10, right: 10 }, tooltip: {}, xAxis: { type: 'category', show: false }, yAxis: yAxis, visualMap: { min: 0, max: 1, show: false, calculable: true, realtime: false, inRange: { color: ['#0000ba', '#29ffdf', '#f9fd0c', '#ff9400'] // color: ['#313695', '#4575b4', '#74add1', '#abd9e9', '#e0f3f8', '#ffffbf', '#fee090', '#fdae61', '#f46d43', '#d73027', '#a50026'] } }, series: [{ name: '图表1', type: 'heatmap', itemStyle: { emphasis: { borderColor: '#333', borderWidth: 1 } }, progressive: false, animation: false, data: d }] }); }); </script> </body> </html>