123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229 |
- <template>
- <v-chart
- class="chart"
- :option="option"
- v-if="JSON.stringify(option) != '{}'"
- />
- </template>
- <script setup lang="ts">
- import { ref, onMounted } from "vue";
- import { graphic } from "echarts/core";
- import Mock from "mockjs";
- const option = ref({});
- const getData = () => {
- // window["$message"]({
- // text: res.msg,
- // type: "warning",
- // });
- const data = Mock.mock({
- xdata: ['2023-07', '2023-08', '2023-09', '2023-10', '2023-11', "2023-12"],
- "yData|6": ["@integer(0, 1000)"],
- "yData2|6": ["@integer(0, 1000)"],
- })
- setTimeout(() => {
- setOption(data);
- }, 100);
- }
- const setOption = async (data:any) => {
- option.value = {
- xAxis: {
- type: "category",
- data: data.xdata,
- boundaryGap: false, // 不留白,从原点开始
- splitLine: {
- show: true,
- lineStyle: {
- color: "rgba(31,99,163,.2)",
- },
- },
- axisLine: {
- // show:false,
- lineStyle: {
- color: "rgba(31,99,163,.1)",
- },
- },
- axisLabel: {
- color: "#7EB7FD",
- fontWeight: "500",
- },
- },
- yAxis: {
- type: "value",
- splitLine: {
- show: true,
- lineStyle: {
- color: "rgba(31,99,163,.2)",
- },
- },
- axisLine: {
- lineStyle: {
- color: "rgba(31,99,163,.1)",
- },
- },
- axisLabel: {
- color: "#7EB7FD",
- fontWeight: "500",
- },
- },
- tooltip: {
- trigger: "axis",
- backgroundColor: "rgba(0,0,0,.6)",
- borderColor: "rgba(147, 235, 248, .8)",
- textStyle: {
- color: "#FFF",
- },
- },
- grid: {
- //布局
- show: true,
- left: "10px",
- right: "30px",
- bottom: "10px",
- top: "32px",
- containLabel: true,
- borderColor: "#1F63A3",
- },
- series: [
- {
- data: data.yData,
- type: "line",
- smooth: true,
- symbol: "none", //去除点
- name: "最高1次数",
- color: "rgba(252,144,16,.7)",
- areaStyle: {
- //右,下,左,上
- color: new graphic.LinearGradient(
- 0,
- 0,
- 0,
- 1,
- [
- {
- offset: 0,
- color: "rgba(252,144,16,.7)",
- },
- {
- offset: 1,
- color: "rgba(252,144,16,.0)",
- },
- ],
- false
- ),
- },
- markPoint: {
- data: [
- {
- name: "最大值",
- type: "max",
- valueDim: "y",
- symbol: "rect",
- symbolSize: [60, 26],
- symbolOffset: [0, -20],
- itemStyle: {
- color: "rgba(0,0,0,0)",
- },
- label: {
- color: "#FC9010",
- backgroundColor: "rgba(252,144,16,0.1)",
- borderRadius: 6,
- padding: [7, 14],
- borderWidth: 0.5,
- borderColor: "rgba(252,144,16,.5)",
- formatter: "峰值1:{c}",
- },
- },
- {
- name: "最大值",
- type: "max",
- valueDim: "y",
- symbol: "circle",
- symbolSize: 6,
- itemStyle: {
- color: "#FC9010",
- shadowColor: "#FC9010",
- shadowBlur: 8,
- },
- label: {
- formatter: "",
- },
- },
- ],
- },
- },
- {
- data: data.yData2,
- type: "line",
- smooth: true,
- symbol: "none", //去除点
- name: "最高2次数",
- color: "rgba(9,202,243,.7)",
- areaStyle: {
- //右,下,左,上
- color: new graphic.LinearGradient(
- 0,
- 0,
- 0,
- 1,
- [
- {
- offset: 0,
- color: "rgba(9,202,243,.7)",
- },
- {
- offset: 1,
- color: "rgba(9,202,243,.0)",
- },
- ],
- false
- ),
- },
- markPoint: {
- data: [
- {
- name: "最大值",
- type: "max",
- valueDim: "y",
- symbol: "rect",
- symbolSize: [60, 26],
- symbolOffset: [0, -20],
- itemStyle: {
- color: "rgba(0,0,0,0)",
- },
- label: {
- color: "#09CAF3",
- backgroundColor: "rgba(9,202,243,0.1)",
- borderRadius: 6,
- borderColor: "rgba(9,202,243,.5)",
- padding: [7, 14],
- formatter: "峰值2:{c}",
- borderWidth: 0.5,
- },
- },
- {
- name: "最大值",
- type: "max",
- valueDim: "y",
- symbol: "circle",
- symbolSize: 6,
- itemStyle: {
- color: "#09CAF3",
- shadowColor: "#09CAF3",
- shadowBlur: 8,
- },
- label: {
- formatter: "",
- },
- },
- ],
- },
- },
- ],
- };
- };
- onMounted(() => {
- getData();
- });
- </script>
- <style scoped lang="scss"></style>
|