| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114 |
- <template>
- <div class="echartsDome">
- <div class="echartsDome_title">{{ title }}</div>
- <div class="echartsDome_chart" ref="chartContainer"></div>
- </div>
- </template>
- <script>
- import * as echarts from "echarts";
- export default {
- name: "EchartsDome",
- props: {
- title: {
- type: String,
- default: "图表标题",
- },
- },
- data() {
- return {
- chart: null,
- };
- },
- mounted() {
- this.initChart();
- },
- methods: {
- initChart() {
- this.chart = echarts.init(this.$refs.chartContainer);
- let option = {
- tooltip: {
- trigger: "axis", // 坐标轴触发提示
- axisPointer: { type: "shadow" },
- },
- legend: {
- data: ["tokyo", "london"],
- textStyle: { color: "#fff" }, // 图例文字颜色
- },
- xAxis: {
- type: "category",
- data: [
- "Jan",
- "Feb",
- "Mar",
- "Apr",
- "May",
- "Jun",
- "Jul",
- "Aug",
- "Sep",
- "Oct",
- "Nov",
- ],
- axisLine: { lineStyle: { color: "#fff" } }, // 坐标轴颜色
- axisTick: { show: false }, // 隐藏刻度
- splitLine: { show: false }, // 隐藏分割线
- },
- yAxis: {
- type: "value",
- max: 30,
- axisLine: { lineStyle: { color: "#fff" } },
- splitLine: {
- lineStyle: {
- type: "dashed", // 虚线网格
- color: "#fff",
- },
- },
- },
- series: [
- {
- name: "调用次数",
- type: "line",
- data: [7, 7, 15, 19, 21, 22, 25, 26, 23, 19, 12], // 模拟数据
- lineStyle: { color: "#42a5f5" }, // 蓝色线条
- itemStyle: { color: "#42a5f5" }, // 节点颜色
- symbol: "circle", // 节点形状
- symbolSize: 6, // 节点大小
- },
- {
- name: "平均响应时间",
- type: "line",
- data: [3, 3, 6, 12, 15, 17, 18, 17, 14, 10, 6], // 模拟数据
- lineStyle: { color: "#4caf50" }, // 绿色线条
- itemStyle: { color: "#4caf50" },
- symbol: "circle",
- symbolSize: 6,
- },
- ],
- };
- // 绘制图表
- this.chart.setOption(option);
- },
- },
- };
- </script>
- <style scoped>
- .echartsDome {
- width: 100%;
- height: 400px;
- /* background-color: #222;
- color: #fff; */
- padding: 20px;
- box-sizing: border-box;
- }
- .echartsDome_title {
- font-size: 16px;
- /* font-weight: bold; */
- }
- .echartsDome_chart {
- width: 100%;
- height: 360px;
- }
- </style>
|