这个是HTML的实例,还没做成组件
<!--
THIS EXAMPLE WAS DOWNLOADED FROM https://echarts.apache.org/examples/zh/editor.html?c=line-tooltip-touch
-->
<!DOCTYPE html>
<html style="height: 100%">
<head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">
</head>
<style type="text/css">
</style>
<body style="height: 560px; margin: 0" class="content">
<div id="container" style="height: 20rem;"></div>
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/echarts@5.3.0/dist/echarts.min.js"></script>
<!-- Uncomment this line if you want to dataTool extension
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/echarts@5.3.0/dist/extension/dataTool.min.js"></script>
-->
<!-- Uncomment this line if you want to use gl extension
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/echarts-gl@2/dist/echarts-gl.min.js"></script>
-->
<!-- Uncomment this line if you want to echarts-stat extension
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/echarts-stat@latest/dist/ecStat.min.js"></script>
-->
<!-- Uncomment this line if you want to use map
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/echarts@5.3.0/map/js/china.js"></script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/echarts@5.3.0/map/js/world.js"></script>
-->
<!-- Uncomment these two lines if you want to use bmap extension
<script type="text/javascript" src="https://api.map.baidu.com/api?v=2.0&ak=<Your Key Here>"></script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/echarts@{{version}}/dist/extension/bmap.min.js"></script>
-->
<script type="text/javascript">
var dom = document.getElementById("container");
var myChart = echarts.init(dom);
var option = {
dataZoom: [
{
type: 'inside',
throttle: '50',
minValueSpan: 6,
start: 1,
end: 50,
zoomLock: true
}
],
grid: {
left: '15%',
top: '10%'
},
tooltip: {
trigger: 'axis',
backgroundColor: '#505050',
textStyle:{
color: '#ffffff'
},
formatter: function (params, ticket, callback) {
var text = params[0].data.date + ': ' + params[0].data.value;
return text;
},
position: function (point, params, dom, rect, size) {
return 'top';
}
},
xAxis: {
type: 'category',
nameTextStyle: {
fontSize: 30
},
axisLine: {
lineStyle: {
color: '#E5E5E5'
}
},
axisLabel: {
show: true,
color: '#000000'
},
axisPointer: {
type: 'line',
handle: {
show: true,
color: '#969696',
size:20
},
},
axisTick: {
show: true
},
data: [
'1月',
'2月',
'3月',
'4月',
'5月',
'6月',
'7月',
'8月',
'9月',
'10月',
'11月',
'12月'
]
},
yAxis: {
type: 'value',
axisLine: {
show: false
},
axisLabel: {
show: true,
color: '#999'
},
axisTick: {
show: false
},
splitNumber: 5
},
series: [
{
type: 'line',
data: [
{
value: 1222,
date: '2019年1月'
},
{
value: 1020,
date: '2019年2月'
},
{
value: 1070,
date: '2019年3月'
},
{
value: 1001,
date: '2019年4月'
},
{
value: 1800,
date: '2019年5月'
},
{
value: 1200,
date: '2019年6月'
},
{
value: 1300,
date: '2019年7月'
},
{
value: 1030,
date: '2019年8月'
},
{
value: 1050,
date: '2019年9月'
},
{
value: 1800,
date: '2019年10月'
},
{
value: 1003,
date: '2019年11月'
},
{
value: 1070,
date: '2019年12月'
}
],
lineStyle: {
color: '#ffaa00',
width: 1
},
itemStyle: {
normal: {
color: '#ffaa00'
},
emphasis: {
color: '#ffaa00'
}
},
symbol: 'emptyCircle',
symbolSize: 6
}
]
};
if (option && typeof option === 'object') {
myChart.setOption(option);
}
</script>
</body>
</html>
晚点做成组件。
|