123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457 |
- function fontSize(res) {
- let font_size = window.getComputedStyle(document.documentElement).fontSize.replace("px", "") * 1;
- return res * font_size;
- }
- function initEcharts() {
- //饼形图
- var myChart = echarts.init(document.getElementById("ring"));
- var option = {
- backgroundColor: "transparent",
- legend: {
- show: false,
- top: "0%",
- left: "center",
- icon: "roundRect",
- itemWidth: 8,
- textStyle: {
- fontSize: fontSize(0.68),
- },
- },
- series: [
- {
- type: "pie",
- radius: "80%",
- center: ["50%", "50%"],
- avoidLabelOverlap: false,
- itemStyle: {
- borderType: "solid",
- borderColor: "#ffffff",
- },
- emphasis: {
- scale: false,
- scaleSize: 2,
- },
- label: {
- show: true,
- position: "center",
- lineHeight: 28,
- formatter: function (params) {
- if (params.dataIndex === self.left_index) {
- return "{p|" + params.data.value + "}" + "\n{nm|" + params.data.name + "}";
- } else {
- return "";
- }
- },
- emphasis: {
- formatter: function (params) {
- if (params.dataIndex != self.left_index) {
- return "{p|" + params.data.name + "}" + "\n{nm|" + params.data.value + "}";
- }
- },
- },
- rich: {
- p: {
- width: 130,
- itemWidth: 100,
- color: "#fff",
- fontSize: fontSize(1),
- lineHeight: fontSize(1),
- fontWeight: "bold",
- // backgroundColor: "rgba(15, 21, 70, 1)", // 覆盖index=0时的数据
- },
- nm: {
- width: 130,
- itemWidth: 100,
- color: "#fff",
- fontSize: fontSize(1.5),
- lineHeight: fontSize(1.625),
- fontWeight: "bold",
- // backgroundColor: "rgba(15, 21, 70, 1)", // 覆盖index=0时的数据
- },
- },
- },
- labelLine: {
- show: false,
- },
- data: [
- {
- value: 64,
- name: "办公建筑",
- itemStyle: {
- color: "rgba(14,227,247, 0.58)",
- },
- },
- {
- value: 1,
- name: "综合建筑",
- itemStyle: {
- color: "rgba(255,113,94, 0.58)",
- },
- },
- {
- value: 4,
- name: "商场建筑",
- itemStyle: {
- color: "rgba(254, 217, 118, 0.64)",
- },
- },
- {
- value: 10,
- name: "宾馆饭店",
- itemStyle: {
- color: "rgba(234,94,230, 0.64)",
- },
- },
- {
- value: 1,
- name: "医疗卫生",
- itemStyle: {
- color: "rgba(94, 225, 186, 0.58)",
- },
- },
- {
- value: 1,
- name: "文化教育",
- itemStyle: {
- color: "rgba(113, 204, 78, 0.58)",
- },
- },
- ],
- },
- ],
- };
- myChart.setOption(option);
- //柱状图
- var myChart2 = echarts.init(document.getElementById("bar"), "dark");
- var option2 = {
- backgroundColor: "transparent",
- tooltip: {
- trigger: "axis",
- show: true,
- confine: true,
- textStyle: {
- align: "left",
- },
- formatter: function (item) {
- let html = `${item[0].name}:${item[0].data}`;
- item.slice(1).forEach((s) => {
- if (s.seriesName.indexOf("series") == -1) {
- html += `<br/> ${s.seriesName}:${s.data}`;
- }
- });
- return html;
- },
- axisPointer: {
- // 坐标轴指示器,坐标轴触发有效
- type: "none", // cross 默认为直线,可选为:'line' | 'shadow'
- },
- },
- legend: {
- show: false,
- top: "5%",
- left: "center",
- icon: "roundRect",
- itemWidth: 8,
- textStyle: {
- fontSize: fontSize(0.6875),
- },
- },
- grid: {
- left: "0%",
- right: "0%",
- top: "20%",
- bottom: "5%",
- containLabel: true,
- },
- xAxis: {
- type: "category",
- data: ["办公建筑", "综合建筑", "商场建筑", "宾馆饭店", "医疗卫生", "文化教育"],
- axisTick: {
- alignWithLabel: false,
- show: true,
- lineStyle: {
- color: "#ccc",
- },
- },
- axisLabel: {
- fontSize: fontSize(0.6875),
- interval: 0,
- padding: [10, 0, 0, 0],
- },
- axisLine: {
- lineStyle: {
- color: "#ccc",
- },
- },
- splitLine: {
- show: false,
- },
- show: true,
- },
- yAxis: {
- max: 70,
- name: "栋",
- nameTextStyle: {
- // color: "rgba(217, 35, 35, 1)",
- align: "right",
- verticalAlign: "middle",
- borderDashOffset: 0,
- padding: [6, 6, 6, 6],
- },
- axisLabel: {
- // color: '#ff0000',
- fontSize: fontSize(0.6875),
- interval: 0,
- padding: [0, 0, 0, 0],
- },
- splitLine: {
- show: false,
- },
- axisLine: {
- lineStyle: {
- color: "#ccc",
- },
- },
- axisTick: {
- alignWithLabel: false,
- show: true,
- lineStyle: {
- color: "#ccc",
- },
- },
- },
- series: [
- {
- name: "dotted",
- type: "pictorialBar",
- symbol: "rect",
- barGap: "-100%",
- showBackground: true,
- itemStyle: {
- color: "rgba(14,227,247, 1)",
- },
- symbolRepeat: true,
- symbolSize: [12, 4],
- symbolMargin: 1,
- data: [64, 1, 4, 10, 1, 1],
- z: -8,
- },
- {
- type: "bar",
- itemStyle: {
- color: "rgba(0,0,0,0.2)",
- },
- barGap: "-100%",
- barWidth: 12,
- z: -9,
- showBackground: true,
- data: [70, 70, 70, 70, 70, 70],
- },
- ],
- };
- myChart2.setOption(option2);
- // 折线图
- let myChart3 = echarts.init(document.getElementById("line"), "dark");
- var option3 = {
- backgroundColor: "transparent",
- tooltip: {
- trigger: "axis",
- show: true,
- confine: true,
- textStyle: {
- align: "left",
- },
- formatter: function (item) {
- let html = item[0].axisValue * 1 + "月";
- item.slice(0).forEach((s) => {
- if (s.seriesName.indexOf("series") == -1) {
- html += `<br/> ${s.seriesName}:${s.data}%`;
- }
- });
- return html;
- // return '{b0}<br/>{a1}: {c1}<br/>{a2}: {c2}'
- },
- // formatter: '{b0}<br/>{a1}: {c1}<br/>{a2}: {c2}',
- axisPointer: {
- // 坐标轴指示器,坐标轴触发有效
- type: "none", // 默认为直线,可选为:'line' | 'shadow'
- },
- },
- legend: {
- show: true,
- // data:[""]
- top: "0%",
- left: "center",
- icon: "circle",
- type: "scroll",
- itemHeight: fontSize(0.5),
- itemWidth: fontSize(0.5),
- textStyle: {
- fontSize: fontSize(0.6),
- },
- },
- grid: {
- left: "0%",
- right: "0%",
- top: "18%",
- bottom: "5%",
- containLabel: true,
- },
- xAxis: {
- type: "category",
- data: ["01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12"],
- axisTick: {
- alignWithLabel: false,
- show: true,
- lineStyle: {
- color: "#ccc",
- },
- },
- axisLine: {
- lineStyle: {
- color: "#ccc",
- },
- },
- axisLabel: {
- //X轴文字样式
- fontSize: fontSize(0.6875),
- interval: 0,
- padding: [10, 0, 0, 0],
- },
- splitLine: {
- show: false,
- },
- show: true,
- },
- yAxis: {
- // max:100,
- type: "value",
- name: "kwh",
- axisLabel: {
- fontSize: fontSize(0.6875),
- interval: 0,
- padding: [0, 0, 0, 0],
- },
- nameLocation: "end",
- nameTextStyle: {
- align: "right",
- verticalAlign: "middle",
- borderDashOffset: 0,
- padding: [6, 6, 6, 6],
- },
- splitLine: { show: false },
- axisLine: {
- lineStyle: {
- color: "#ccc",
- },
- },
- axisTick: {
- alignWithLabel: false,
- show: true,
- lineStyle: {
- color: "#ccc",
- },
- },
- },
- series: [
- {
- name: "办公建筑",
- type: "line",
- symbol: "circle",
- symbolSize: 5,
- itemStyle: {
- color: "rgba(14,227,247,1)",
- },
- barGap: "-100%",
- barWidth: 12,
- z: -8,
- data: [4, 3, 5, 4, 0],
- },
- {
- name: "综合建筑",
- type: "line",
- symbol: "circle",
- symbolSize: 5,
- itemStyle: {
- color: "rgba(255,113,94, 1)",
- },
- barGap: "-100%",
- barWidth: 12,
- z: -8,
- data: [0.8, 0.6, 1, 0.6, 0],
- },
- {
- name: "商场建筑",
- type: "line",
- symbol: "circle",
- symbolSize: 5,
- itemStyle: {
- color: "rgba(254, 217, 118, 1)",
- },
- barGap: "-100%",
- barWidth: 12,
- z: -8,
- data: [0.6, 0.5, 0.8, 0.4, 0],
- },
- {
- name: "宾馆饭店",
- type: "line",
- symbol: "circle",
- symbolSize: 5,
- itemStyle: {
- color: "rgba(234,94,230, 1)",
- },
- barGap: "-100%",
- barWidth: 12,
- z: -8,
- data: [],
- },
- {
- name: "医疗卫生",
- type: "line",
- symbol: "circle",
- symbolSize: 5,
- itemStyle: {
- color: "rgba(94, 225, 186, 1)",
- },
- barGap: "-100%",
- barWidth: 12,
- z: -8,
- data: [1, 1, 1],
- },
- {
- name: "文化教育",
- type: "line",
- symbol: "circle",
- symbolSize: 5,
- itemStyle: {
- color: "rgba(113, 204, 78, 1)",
- },
- barGap: "-100%",
- barWidth: 12,
- z: -8,
- data: [1, 2, 1, 1, 2],
- },
- {
- type: "bar",
- itemStyle: {
- color: "rgba(0,0,0,0.2)",
- },
- barGap: "-100%",
- barWidth: 12,
- z: -9,
- showBackground: true,
- data: [7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7],
- },
- ],
- };
- myChart3.setOption(option3);
- }
|