|
@@ -0,0 +1,113 @@
|
|
|
+<template>
|
|
|
+ <div class="hello">
|
|
|
+ <div id="chart_1" style="width: 100%;height:400px;"></div>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+export default {
|
|
|
+ name: "HelloWorld",
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ orgOptions: {}
|
|
|
+ };
|
|
|
+ },
|
|
|
+ mounted() {
|
|
|
+ this.drawChart();
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ drawChart() {
|
|
|
+ // 基于准备好的dom,初始化echarts实例
|
|
|
+ let myChart = this.$echarts.init(
|
|
|
+ document.getElementById("chart_1")
|
|
|
+ );
|
|
|
+ // 指定图表的配置项和数据
|
|
|
+ let option = {
|
|
|
+ title: {
|
|
|
+ text: "耳根温度 36.4℃",
|
|
|
+ subtext: "纯属虚构",
|
|
|
+ left: 100
|
|
|
+ },
|
|
|
+ tooltip: {
|
|
|
+ trigger: "axis"
|
|
|
+ },
|
|
|
+ toolbox: {
|
|
|
+ show: true,
|
|
|
+ feature: {
|
|
|
+ dataZoom: {
|
|
|
+ yAxisIndex: "none"
|
|
|
+ },
|
|
|
+ dataView: { readOnly: false },
|
|
|
+ magicType: { type: ["line", "bar"] },
|
|
|
+ restore: {},
|
|
|
+ saveAsImage: {}
|
|
|
+ }
|
|
|
+ },
|
|
|
+ color: {
|
|
|
+ type: "linear",
|
|
|
+ x: 0,
|
|
|
+ y: 0,
|
|
|
+ x2: 0,
|
|
|
+ y2: 1,
|
|
|
+ colorStops: [
|
|
|
+ {
|
|
|
+ offset: 0,
|
|
|
+ color: "red" // 0% 处的颜色
|
|
|
+ },
|
|
|
+ {
|
|
|
+ offset: 1,
|
|
|
+ color: "blue" // 100% 处的颜色
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ xAxis: {
|
|
|
+ type: "category",
|
|
|
+ boundaryGap: false,
|
|
|
+ data: [
|
|
|
+ "七分钟前",
|
|
|
+ "六分钟前",
|
|
|
+ "五分钟前",
|
|
|
+ "四分钟前",
|
|
|
+ "三分钟前",
|
|
|
+ "两分钟前",
|
|
|
+ "当前"
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ yAxis: {
|
|
|
+ type: "value",
|
|
|
+ axisLabel: {
|
|
|
+ formatter: "{value} °C"
|
|
|
+ },
|
|
|
+ scale: true
|
|
|
+ },
|
|
|
+ series: [
|
|
|
+ {
|
|
|
+ name: "耳温",
|
|
|
+ type: "line",
|
|
|
+ data: [32.5, 32.6, 32.4, 32.5, 32.4, 32.6, 32.4],
|
|
|
+ markPoint: {
|
|
|
+ data: [
|
|
|
+ { type: "max", name: "最大值" },
|
|
|
+ { type: "min", name: "最小值" }
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ markLine: {
|
|
|
+ data: [{ type: "average", name: "平均值" }]
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ };
|
|
|
+ // 使用刚指定的配置项和数据显示图表。
|
|
|
+ myChart.setOption(option);
|
|
|
+ }
|
|
|
+ }
|
|
|
+};
|
|
|
+</script>
|
|
|
+
|
|
|
+<style lang="scss" scoped>
|
|
|
+.hello {
|
|
|
+ .chart {
|
|
|
+ width: 100%;
|
|
|
+ }
|
|
|
+}
|
|
|
+</style>
|