shop/echarts-master/test/graph-case.html
2025-05-03 23:48:15 +08:00

465 lines
13 KiB
HTML
Generated

<!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>
<div id="main1"></div>
<div id="main2"></div>
<div id="main3"></div>
<script>
require([
'echarts',
// 'map/js/china',
// './data/nutrients.json'
], function (echarts) {
var option;
option = {
"series": [
{
"type": "graph",
"layout": "none",
"label": {
"show": true
},
"data": [
{
"name": "数据中心0边框1",
"x": -33,
"y": -15,
"symbol": 'none'
},
{
"name": "数据中心0边框2",
"x": 10,
"y": 10
},
{
"name": "数据中心0边框3",
"x": -30,
"y": 10
}
],
}
]
};
var chart = testHelper.create(echarts, 'main0', {
title: [
'Should not throw error if symbol is none',
'Case from https://github.com/apache/echarts/issues/16366'
],
option: option
// height: 300,
// buttons: [{text: 'btn-txt', onclick: function () {}}],
// recordCanvas: true,
});
});
</script>
<script>
require(['echarts'], function (echarts) {
var option = {
legend: {},
series: {
type: 'graph',
name: 'graph',
edgeLabel: {
show: true,
fontSize: 16
},
lineStyle: {
width: 5,
curveness: 0.2,
opacity: 0.9
},
data: [
{
x: 10,
y: 100,
name: 'Node 1'
},
{
x: 100,
y: -50,
name: 'Node 2'
},
{
x: 400,
y: 200,
name: 'Node 3'
}
],
links: [
{
source: 'Node 1',
target: 'Node 2'
},
{
source: 'Node 1',
target: 'Node 3'
},
{
source: 'Node 2',
target: 'Node 3'
}
]
}
};
var chart = testHelper.create(echarts, 'main1', {
title: [
'Should not throw error when hiding by legend'
],
option: option
});
});
</script>
<script>
require(['echarts'], function (echarts) {
var option = {
series: [{
type: 'graph',
layout: 'force',
roam: true,
data: [
{
name: 'Node 1',
x: 300,
y: 300
},
{
name: 'Node 2',
x: 800,
y: 300
}
],
links: [
{
source: 'Node 1',
target: 'Node 2'
}
]
}]
};
var chart = testHelper.create(echarts, 'main2', {
title: [
'Layout timer should stop after disposing chart'
],
buttons: [
{
text: 'Dispose',
onclick() {
const seriesModel = chart.getModel().getSeriesByType('graph')[0]
const graphView = chart.getViewOfSeriesModel(seriesModel)
const container = chart.getDom()
chart.dispose()
if (graphView._layoutTimeout) {
const errMsg = 'Graph layout timer is not removed after disposing the chart!'
container.innerHTML = '<b style="color: red">' + errMsg + '</b>'
throw new Error(errMsg)
}
}
}
],
option: option
});
});
</script>
<script>
require(['echarts'], function (echarts) {
var option = {
xAxis: { show: false, type: 'value', min: 0, max: 503 },
yAxis: { show: false, type: 'value', min: 0, max: 810 },
series: [
{
name: '马王堆一号+',
type: 'graph',
coordinateSystem: 'cartesian2d',
symbol: 'circle',
emphasis: { focus: 'adjacency' },
z: 3,
scaleLimit: { min: 0.5, max: 2 },
draggable: true,
roam: 'scale',
label: {
show: true,
position: 'bottom',
color: 'black',
fontWeight: 'bold'
},
data: [
{
value: [430, 257],
id: '1',
name: '入职指导',
symbolSize: 51,
attributes: {},
itemStyle: { color: '#3ba272' }
},
{
value: [468, 684],
id: '2',
name: '开发规范参考',
symbolSize: 20,
attributes: {},
itemStyle: { color: '#fc8452' }
},
{
value: [487, 326],
id: '3',
name: 'Web 前端',
symbolSize: 59,
attributes: {},
itemStyle: { color: '#9a60b4' }
},
{
value: [238, 121],
id: '4',
name: '响应式分享',
symbolSize: 51,
attributes: {},
itemStyle: { color: '#ea7ccc' }
},
{
value: [394, 529],
id: '5',
name: '技术文档',
symbolSize: 20,
attributes: {},
itemStyle: { color: '#cfb850' }
},
{
value: [261, 369],
id: '6',
name: '组件库方案',
symbolSize: 57,
attributes: {},
itemStyle: { color: '#4ee0d7' }
},
{
value: [125, 366],
id: '7',
name: '数字文博 C 端 Web 技术选型',
symbolSize: 41,
attributes: {},
itemStyle: { color: '#e3698c' }
},
{
value: [230, 55],
id: '8',
name: '3D 展示调研',
symbolSize: 60,
attributes: {},
itemStyle: { color: '#e3698c' }
},
{
value: [195, 447],
id: '9',
name: '送审方案',
symbolSize: 46,
attributes: {},
itemStyle: { color: '#eca389' }
},
{
value: [367, 645],
id: '10',
name: '蜂鸟go-ceres开发规范',
symbolSize: 30,
attributes: {},
itemStyle: { color: '#6939e4' }
},
{
value: [350, 701],
id: '11',
name: '分库分表规范',
symbolSize: 57,
attributes: {},
itemStyle: { color: '#9f73c7' }
}
],
edges: [
{ source: '2', target: '9' },
{ source: '2', target: '10' },
{ source: '2', target: '11' },
{ source: '3', target: '1' },
{ source: '3', target: '2' },
{ source: '3', target: '5' },
{ source: '3', target: '7' },
{ source: '3', target: '8' },
{ source: '5', target: '4' },
{ source: '5', target: '7' },
{ source: '5', target: '8' },
{ source: '7', target: '5' },
{ source: '7', target: '6' },
{ source: '7', target: '9' },
{ source: '9', target: '10' }
],
lineStyle: { color: 'orange', curveness: 0, width: 1, type: 'solid' }
},
{
name: '线图',
type: 'lines',
coordinateSystem: 'cartesian2d',
effect: {
show: true,
trailLength: 0,
symbol: 'circle',
color: 'red',
symbolSize: 6,
constantSpeed: 60
},
z: 1,
lineStyle: { width: 0 },
data: [
{
coords: [
[468, 684],
[195, 447]
]
},
{
coords: [
[468, 684],
[367, 645]
]
},
{
coords: [
[468, 684],
[350, 701]
]
},
{
coords: [
[487, 326],
[430, 257]
]
},
{
coords: [
[487, 326],
[468, 684]
]
},
{
coords: [
[487, 326],
[394, 529]
]
},
{
coords: [
[487, 326],
[125, 366]
]
},
{
coords: [
[487, 326],
[230, 55]
]
},
{
coords: [
[394, 529],
[238, 121]
]
},
{
coords: [
[394, 529],
[125, 366]
]
},
{
coords: [
[394, 529],
[230, 55]
]
},
{
coords: [
[125, 366],
[394, 529]
]
},
{
coords: [
[125, 366],
[261, 369]
]
},
{
coords: [
[125, 366],
[195, 447]
]
},
{
coords: [
[195, 447],
[367, 645]
]
}
]
}
]
};
var chart = testHelper.create(echarts, 'main3', {
option,
title: [
'Hover on the symbols or lines, **SHOULD NOT** throw NPE',
'See also https://github.com/apache/echarts/issues/19900'
]
});
});
</script>
</body>
</html>