NuclearDispersionSystem/ant-design-vue-jeecg/node_modules/@antv/g2-brush/demos/line.html
2023-09-14 14:47:11 +08:00

100 lines
2.0 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<meta name="geometry" content="diagram">
<link rel="stylesheet" href="./assets/common.css">
<title>Line Chart(XY)</title>
</head>
<body>
<div id="canvas"></div>
<script src="./assets/jquery-3.2.1.min.js"></script>
<script src="./assets/data-set.min.js"></script>
<script src="./assets/g2.min.js"></script>
<script src="../build/g2-brush.js"></script>
<script>
$.getJSON('./data/avg-temp.json', function(data) {
const { DataView } = DataSet;
const dv = new DataView();
dv.source(data)
.transform({
type: 'fold',
key: 'city',
value: 'value',
fields: [ 'New York', 'San Francisco', 'Austin' ]
});
const chart = new G2.Chart({
id: 'canvas',
forceFit: true,
height: 400,
padding: [ 60, 30, 30 ]
});
chart.source(dv, {
date: {
type: 'time'
},
value: {
alias: 'Temperature, ºF'
}
});
chart.legend({
position: 'top'
});
chart.axis('date', {
line: {
stroke: '#000'
},
tickLine: {
stroke: '#000',
value: 6 // 刻度线长度
},
label: {
textStyle: {
textAlign: 'start'
}
}
});
chart.axis('value', {
tickLine: {
stroke: '#000',
value: 6 // 刻度线长度
},
label: {
textStyle: {
fill: '#000'
}
},
line: {
stroke: '#000'
},
grid: null
});
chart.line()
.position('date*value')
.color('city')
.shape('spline')
.size(2);
chart.render();
new Brush({
canvas: chart.get('canvas'),
style: {
fill: '#ccc',
fillOpacity: 0.4
},
chart
});
chart.on('plotdblclick', () => {
chart.get('options').filters = {};
chart.repaint();
});
});
</script>
</body>
</html>