/
githubmirror
/
echarts
Обзор
Документация
Войти
/
githubmirror
/
echarts
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
test/pie-coordinate-system.html
426 строк
16 KB
100pah
fix(pie-on-cartesian): Previously when pie is located on Cartesian, axes extent can not union pie center automatically. Commit
18a23a8
has supported it. This commit updates test cases.
25 янв 2026, 18:11
25 янв 2026, 18:11
28e74ef
Код
Авторство
О чём код?
<!-- 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"> <!-- THESE MAP API KEYS ARE ONLY FOR TESTING USAGE!!! --> <script src="lib/simpleRequire.js"></script> <script src="lib/config.js"></script> <script src="lib/dat.gui.min.js"></script> <link rel="stylesheet" href="lib/reset.css" /> <script src="lib/testHelper.js"></script> </head> <body> <style> </style> <div id="main1"></div> <div id="main2"></div> <div id="main3"></div> <div id="main4"></div> <div id="main_pie_on_cartesian2d"></div> <div id="main7"></div> <script> require([ 'echarts' ], function (echarts) { var pieRadius = 20; var option = { calendar: { top: 'middle', left: 'center', cellSize: pieRadius * 3, orient: 'vertical', range: ['2022-05'] }, tooltip: {}, series: [ { type: 'pie', name: 'Calendar', coordinateSystem: 'calendar', radius: pieRadius, // center is date when displayed on calendar center: '2022-05-16', data: [ { value: 1048, name: 'A' }, { value: 735, name: 'B' }, { value: 580, name: 'C' }, { value: 484, name: 'D' }, { value: 300, name: 'E' } ], label: { show: false } }, { type: 'pie', name: 'Calendar', coordinateSystem: 'calendar', radius: pieRadius, center: '2022-05-05', data: [ { value: 1048, name: 'A' }, { value: 735, name: 'B' }, { value: 580, name: 'C' }, { value: 484, name: 'D' }, { value: 300, name: 'E' } ], label: { show: false } } ] }; testHelper.create(echarts, 'main1', { title: ['Pie series on Calendar'], option: option }) }); </script> <script> require([ 'echarts', 'map/js/china' ], function (echarts) { var option = { title: [{ text: '地图数据来源:天地图 cloudcenter.tianditu.gov.cn', subtext: '仅作为功能测试使用,线上产品应从天地图获取最新地图数据并申请审图号', link: 'https://cloudcenter.tianditu.gov.cn/', bottom: 15, left: 15, textStyle: { color: '#888', fontSize: 12 }, subtextStyle: { color: '#aaa', fontSize: 12 } }], geo: { map: 'china', roam: true, center: [104.2, 36], zoom: 1.4 }, tooltip: {}, series: [ { type: 'pie', name: 'Geo', coordinateSystem: 'geo', radius: 20, center: [120, 30], data: [ { value: 1048, name: 'A' }, { value: 735, name: 'B' }, { value: 580, name: 'C' }, { value: 484, name: 'D' }, { value: 300, name: 'E' } ] }, { type: 'pie', name: 'Geo', coordinateSystem: 'geo', radius: 20, center: '北京市', data: [ { value: 1048, name: 'A' }, { value: 735, name: 'B' }, { value: 580, name: 'C' }, { value: 484, name: 'D' }, { value: 300, name: 'E' } ] } ] }; testHelper.create(echarts, 'main2', { title: ['Pie series on Geo Map'], option: option }) }); </script> <script> require([ 'echarts', 'data/svg/Map_of_Iceland.svg' ], function (echarts, svg) { echarts.registerMap('Map_of_Iceland', { svg: svg }); var option = { geo: { map: 'Map_of_Iceland', roam: true, }, tooltip: {}, series: [ { type: 'pie', name: 'Geo SVG', coordinateSystem: 'geo', radius: 20, center: [1062, 955], data: [ { value: 1048, name: 'A' }, { value: 735, name: 'B' }, { value: 580, name: 'C' }, { value: 484, name: 'D' }, { value: 300, name: 'E' } ] } ] }; testHelper.create(echarts, 'main3', { title: ['Pie series on Geo SVG'], option: option }) }); </script> <script> require([ 'echarts' ], function (echarts) { var option = { tooltip: {}, grid: [ { id: 'a', left: 20, width: '40%', }, { id: 'b', right: 20, width: '40%', } ], xAxis: [{ id: 'a', gridId: 'a', type: 'category', data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'], }, { id: 'b', gridId: 'b', type: 'category', data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'], }], yAxis: [{ id: 'a', gridId: 'a', type: 'category', data: ['A', 'B', 'C', 'D', 'E', 'F', 'G'] }, { id: 'b', gridId: 'b', type: 'category', data: ['A', 'B', 'C', 'D', 'E', 'F', 'G'] }], series: [ { type: 'pie', name: 'Cartesian2D(Category Axes) 1', coordinateSystem: 'cartesian2d', radius: 20, center: ['Tue', 'E'], xAxisId: 'a', yAxisId: 'a', data: [ { value: 1048, name: 'A' }, { value: 735, name: 'B' }, { value: 580, name: 'C' }, { value: 484, name: 'D' }, { value: 300, name: 'E' } ] }, { type: 'pie', name: 'Cartesian2D(Category Axes) 2', coordinateSystem: 'cartesian2d', radius: 40, center: ['Wed', 'C'], xAxisId: 'b', yAxisId: 'b', data: [ { value: 48, name: 'A' }, { value: 135, name: 'B' }, { value: 280, name: 'C' }, { value: 984, name: 'D' }, { value: 600, name: 'E' } ] } ] }; testHelper.create(echarts, 'main4', { title: ['Pie series on Cartesian2D', 'Category Axes'], option: option }) }); </script> <script> require([ 'echarts' ], function (echarts) { var option = { tooltip: {}, xAxis: { type: 'category', data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'] }, yAxis: { type: 'value' }, series: [ { type: 'pie', name: 'Cartesian2D(category axis & value axis)', coordinateSystem: 'cartesian2d', radius: 20, center: ['Tue', 230], data: [ { value: 1048, name: 'use_center' }, { value: 735, name: 'B' }, { value: 580, name: 'C' }, { value: 484, name: 'D' }, { value: 300, name: 'E' } ] }, { type: 'pie', name: 'Cartesian2D(category axis & value axis)', coordinateSystem: 'cartesian2d', radius: 20, coord: ['Fri', 130], data: [ { value: 1048, name: 'use_coord' }, { value: 735, name: 'B' }, { value: 580, name: 'C' }, { value: 484, name: 'D' }, { value: 300, name: 'E' } ] }, ] }; testHelper.create(echarts, 'main_pie_on_cartesian2d', { title: [ 'Pie series on Cartesian2D', 'category axis & value axis (**pie center should be auto-added into axis extent union**)' ], option: option }) }); </script> <script> require([ 'echarts', 'data/usa.json' ], function (echarts, usaJSON) { echarts.registerMap('USA', usaJSON, { Alaska: { left: -131, top: 25, width: 15 }, Hawaii: { left: -110, top: 28, width: 5 }, 'Puerto Rico': { left: -76, top: 26, width: 2 } }); function randomPieSeries(center, radius) { const data = ['A', 'B', 'C', 'D'].map((t) => { return { value: Math.round(Math.random() * 100), name: 'Category ' + t }; }); return { type: 'pie', coordinateSystem: 'geo', tooltip: { formatter: '{b}: {c} ({d}%)' }, label: { show: false }, labelLine: { show: false }, animationDuration: 0, radius, center, data }; } var option = { geo: { map: 'USA', roam: true, itemStyle: { areaColor: '#e7e8ea' } }, tooltip: {}, legend: {}, series: [ randomPieSeries([-86.753504, 33.01077], 15), randomPieSeries([-116.853504, 39.8], 25), randomPieSeries([-99, 31.5], 30), // This name string should work randomPieSeries('Alaska', 20) ] }; testHelper.create(echarts, 'main7', { title: ['Pie series on Geo Map', 'A pie series should be displayed at `**Alaska**`'], option: option }); }); </script> </body> </html>