This commit is contained in:
duanxiaohai 2024-04-16 14:08:11 +08:00
parent deddd645c3
commit 7bc30105e2
2 changed files with 231 additions and 3 deletions

229
src/view/echarts/ylXZZC.vue Normal file
View File

@ -0,0 +1,229 @@
<template>
<div
ref="chart"
style="width: 100%; height: calc(100% - 46px); min-height: 150px"
></div>
</template>
<script setup>
import { onMounted, reactive, ref } from "vue";
// echarts
import * as echarts from "echarts";
const chart = ref(null); // DOM
const data = ["大街乡", "社阳乡", "沐尘畲族乡", "庙下乡", "溪口镇", "罗家乡"];
const datas = ["8", "10", "7", " 23", "25", "250"];
let zoomShow = true;
// if (data.length > 7) {
// zoomShow = true;
// } else {
// zoomShow = false;
// }
let option = {
tooltip: {
trigger: "axis",
axisPointer: {
type: "shadow",
},
},
legend: {},
grid: {
top: "-2%",
left: "3%",
right: "8%",
bottom: "3%",
containLabel: true,
// containLabel:false,
color: "#ffffff",
},
// dataZoom: [
// {//
// show: zoomShow,
// type: "inside",
// startValue: 0,
// endValue: 2,
// minValueSpan: 2,
// maxValueSpan: 2,
// yAxisIndex: [0],
// zoomOnMouseWheel: false, //
// moveOnMouseWheel: true, //
// moveOnMouseMove: true, //
// },
// { //使
// show: zoomShow,
// type: "slider",
// realtime: true,
// startValue: 0,
// endValue: 2,
// width: "3.5",
// height: "80%",
// yAxisIndex: [0], // y
// fillerColor: "rgba(154, 181, 215, 1)", //
// borderColor: "rgba(17, 100, 210, 0.12)",
// backgroundColor: "#cfcfcf", //
// handleSize: 0, //
// showDataShadow: false, // auto
// showDetail: false, //
// top: "1%",
// right: "5",//
// },
// ],
dataZoom: [
{
//使
id: "dataZoomY",
type: "slider",
yAxisIndex: [0], // y
filterMode: "empty", //,
width: "10",
height: "100%",
right: "3%", //
orient: "vertical", // 'horizontal''vertical'
start: 0, // ,0 ~ 100
end: 70, //
zoomLock: true, //
fillerColor: "rgba(154, 181, 215, 1)", //
borderColor: "rgba(17, 100, 210, 0.12)",
backgroundColor: "#cfcfcf", //
handleSize: 0, //
showDataShadow: false, // auto
showDetail: false, //
zoomOnMouseWheel: false, //
moveOnMouseWheel: true, //
moveOnMouseMove: true, //
},
],
calculable: true,
xAxis: {
// name: '/',
type: "value",
data: datas,
axisLabel: {
//
textStyle: {
color: "#ffffff",
},
// formatter: `{value}/` // x
formatter: function (value, index) {
if (index === datas.length - 1) {
//
return value + "/次"; //
} else {
return value; //
}
},
},
splitLine: {
//线
show: true,
lineStyle: {
color: "rgba(255, 255, 255, 0.2)",
width: 1,
},
},
axisPointer: {
label: {
autoSplitNumber: 5,
},
},
},
yAxis: {
show:true,
type: "category", //
data: data,
// max:10,
//y
axisLabel: {
inside: false,
// bargap: 0.5, //
textStyle: {
color: "#ffffff",
},
},
axisTick: {
show: false, // x
},
//y线
axisLine: {
"show":true,
lineStyle: {
color: "#ffffff",
width: 1,
type: "solid",
},
},
//
// scrollbar: {
// orient: "vertical",
// //
// height: 100,
// },
//线
splitLine: {
// show: false,
show:true,
lineStyle: {
color: "#ffffff",
width: 1,
},
},
},
series: [
{
type: "bar",
name: "次数",
data: datas,
barWidth: 15, //
barGap: 0.3 /*多个并排柱子设置柱子之间的间距*/,
// barCategoryGap: "10" /**/,
barMaxWidth: 20, //
barMinWidth: 5, //
itemStyle: {
normal: {
borderWidth: 1,
borderColor: "rgba(0, 183, 255, 1)",
borderRadius: [0, 0, 50, 0], //
color: new echarts.graphic.LinearGradient(0, 0, 1, 0, [
{ offset: 0, color: "rgba(26, 255, 217, 0)" },
{ offset: 1, color: "rgba(0, 183, 255, 1)" },
]),
},
},
},
],
};
onMounted(() => {
// domecharts
// var myChart = echarts.init(document.getElementById('main'));
// Vue3
var myChart = echarts.init(chart.value);
// init(); // vue3.2this
// 使
myChart.setOption(option);
// myChart.on("scroll", function (event) {
// // bargap
// var bargap = event.scrollData / 10000; // 1%0.5bargap
// myChart.setOption({
// yAxis: {
// axisLabel: {
// bargap: bargap,
// },
// },
// });
// });
// :
// window.addEventListener("resize", () => {
// myChart.resize();
// });
});
</script>
<style scoped></style>

View File

@ -292,11 +292,10 @@ const change = (name, index) => {
.medicalServiceTop {
position: relative;
span {
position: absolute;
left: 39px;
top: 35%;
left: 4.5vh;
top: 8vh;
font-weight: bold;
font-size: 32px;
color: #ffffff;