| | |
| | | </template> |
| | | |
| | | <script> |
| | | const fileTypeBar = require("@/assets/img/Screen/fileTypeBar.png") |
| | | import * as echarts from "echarts" |
| | | import { countFileFormat } from "@/api/screen.js" |
| | | import { GetTypeVisitsCount } from "@/api/screen.js" |
| | | export default { |
| | | data() { |
| | | return { |
| | |
| | | value: 20, |
| | | }, |
| | | ] |
| | | const res = await countFileFormat() |
| | | const res = await GetTypeVisitsCount() |
| | | let xAxis = [] |
| | | let yAxis = [] |
| | | if (res.code == 200) { |
| | | data = res.result.map(item => { |
| | | return { |
| | | name: item.type, |
| | | value: item.count, |
| | | } |
| | | xAxis.push(item.name) |
| | | yAxis.push(item.count) |
| | | }) |
| | | } |
| | | data.sort((a, b) => b.value - a.value) |
| | | data = data.slice(0, 10) |
| | | let getArrByKey = (data, k) => { |
| | | let key = k || "value" |
| | | let res = [] |
| | | if (data) { |
| | | data.forEach(function (t) { |
| | | res.push(t[key]) |
| | | }) |
| | | } |
| | | return res |
| | | } |
| | | let getSymbolData = data => { |
| | | let arr = [] |
| | | for (var i = 0; i < data.length; i++) { |
| | | arr.push({ |
| | | value: data[i].value, |
| | | symbolPosition: "end", |
| | | }) |
| | | } |
| | | return arr |
| | | } |
| | | let opt = { |
| | | index: 0, |
| | | } |
| | | let color = ["#A71A2B"] |
| | | data = data.sort((a, b) => { |
| | | return b.value - a.value |
| | | }) |
| | | let option = { |
| | | backgroundColor: "transparent", |
| | | grid: { |
| | | top: "2%", |
| | | bottom: "2%", |
| | | right: "5%", |
| | | left: "10%", |
| | | containLabel: true, |
| | | // 让图表占满容器 |
| | | top: "12%", |
| | | left: "15%", |
| | | right: "10%", |
| | | bottom: "15%", |
| | | }, |
| | | tooltip: { |
| | | show: true |
| | | }, |
| | | xAxis: { |
| | | show: false, |
| | | data: xAxis, |
| | | axisLabel: { |
| | | show: true, |
| | | color: "#ffff", |
| | | }, |
| | | axisTick: { |
| | | show: false, |
| | | }, |
| | | axisLine: { |
| | | show: true, |
| | | lineStyle: { |
| | | color: "rgba(95, 180, 237, 0.32)", |
| | | }, |
| | | }, |
| | | }, |
| | | yAxis: [ |
| | | { |
| | | triggerEvent: true, |
| | | show: true, |
| | | inverse: true, |
| | | data: getArrByKey(data, "name"), |
| | | axisLine: { |
| | | show: false, |
| | | }, |
| | | splitLine: { |
| | | show: false, |
| | | }, |
| | | axisTick: { |
| | | show: false, |
| | | }, |
| | | axisLabel: { |
| | | show: false, |
| | | interval: 0, |
| | | color: "#fff", |
| | | align: "left", |
| | | margin: 0, |
| | | fontSize: 13, |
| | | formatter: function (value, index) { |
| | | return "{title|" + value + "}" |
| | | }, |
| | | rich: { |
| | | title: { |
| | | width: 165, |
| | | }, |
| | | }, |
| | | yAxis: { |
| | | axisLine: { |
| | | show: false, |
| | | }, |
| | | axisTick: { |
| | | show: false, |
| | | }, |
| | | axisLabel: { |
| | | color: "#ffff", |
| | | }, |
| | | // 分割线 |
| | | splitLine: { |
| | | lineStyle: { |
| | | color: "#5d7289", |
| | | width: 1, |
| | | type: "dashed", |
| | | }, |
| | | }, |
| | | { |
| | | triggerEvent: true, |
| | | show: true, |
| | | inverse: true, |
| | | data: getArrByKey(data, "name"), |
| | | axisLine: { |
| | | show: false, |
| | | }, |
| | | splitLine: { |
| | | show: false, |
| | | }, |
| | | axisTick: { |
| | | show: false, |
| | | }, |
| | | axisLabel: { |
| | | interval: 0, |
| | | shadowOffsetX: "-20px", |
| | | color: "#fff", |
| | | align: "right", |
| | | verticalAlign: "bottom", |
| | | lineHeight: 20, |
| | | fontSize: 13, |
| | | formatter: function (value, index) { |
| | | return data[index].value |
| | | }, |
| | | }, |
| | | }, |
| | | ], |
| | | }, |
| | | series: [ |
| | | { |
| | | name: "XXX", |
| | | // 顶部圆片 |
| | | type: "pictorialBar", |
| | | symbol: |
| | | "image://data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADoAAAA6CAMAAADWZboaAAAAZlBMVEUAAABe3uVe3+Vf3uVf3+Zf3uVg3+Zg3+Zf3+Vi4OZh4OZg3+Z86/Bh3+Zi4Odj4Odi4OZ86/B76/B86/Bj4ed56+9x5+xn4umB7/N87PB36e+A7/N+7fF/7vJ/7vJ+7fGA7/OB7/PReX+lAAAAIXRSTlMABQkVDREmIhk3MR10LEFFPHh7cUprXE35h2XnqMLAp+mHAG9cAAAB5ElEQVRIx83WjU7CMBQFYIoiKMqU/XUboHv/l/Tce7t2XamDNSacETEmX86tlK2rx4py150o+MstMBLwWRfHKo6JCVxLnvmFGBjFQ58oF1//sUZhGy/ClSTWObgnL4O+bkeN4nY2okfNMbkRt9/vtxz8InoTsWplJSCzFxPmO8+GpSIByX3YQAuGDWtRKhKjCnxDXhF6Z4yxnZ20Wgko7BMRDmxtSGVaI4kdTIgb+zTYoJQlIMlDlmUFgrcDWWC201qSayqlTkiCddWWeV62VU0YlnpRi9VOKaSUsiyq/N0krwq2Ugt7lVpZl5BfHNiytjagMi+XYp0kCR45hMlivVQrE/uU5pXSrCB5bM6d1t2lOZItMqmliT3q5uVxqxzyW/ccfYLNKx7ZTeykMvNyac2yt2Fbc61MHLSC0rwoxbiNdlQ3GBm1NLHQsHUrtEXppR/ljNpW6DbSCoqlFiVoN6YdaFlgsSFVPs1BdT8OaB5QyQzVcaqWDows/zepxR8ObLglTrdtCRVuRNj4Rrxh+//0ke2f8KVL+Kon3GCSbmsJN9OUW3j6g0Ns+LgCij2u0h+Sghc8mlMPBMgdx5DFh59VmOVHrvmDnoNxCz3J7MFWsMuaLyR089xz/xhlfijvwutR8gv3zk6BLUUeCgAAAABJRU5ErkJggg==", |
| | | symbolSize: [35, 35], |
| | | symbolOffset: [20, 0], |
| | | z: 5, |
| | | data: getSymbolData(data), |
| | | animation: false, |
| | | itemStyle: { |
| | | color: "rgba(115, 240, 252, 1)", |
| | | }, |
| | | symbolRepeat: false, |
| | | symbolSize: [15, 8], |
| | | symbolMargin: 1, |
| | | z: 10, |
| | | data: data, |
| | | symbolPosition: "end", |
| | | symbolOffset: [0, -4], |
| | | }, |
| | | { |
| | | name: "条", |
| | | type: "bar", |
| | | showBackground: true, |
| | | barBorderRadius: 10, |
| | | yAxisIndex: 0, |
| | | data: data, |
| | | barWidth: 8, |
| | | // align: left, |
| | | // 底部圆片 |
| | | type: "pictorialBar", |
| | | animation: false, |
| | | |
| | | itemStyle: { |
| | | normal: { |
| | | color: new echarts.graphic.LinearGradient( |
| | | 0, |
| | | 0, |
| | | 1, |
| | | 0, |
| | | [ |
| | | { |
| | | offset: 0, |
| | | color: "#5A9DFF", |
| | | }, |
| | | { |
| | | offset: 0.7, |
| | | color: "#1878FF", |
| | | }, |
| | | { |
| | | offset: 1, |
| | | color: "#164182", |
| | | }, |
| | | ], |
| | | false |
| | | ), |
| | | barBorderRadius: 5, |
| | | }, |
| | | // color: '#A71A2B', |
| | | barBorderRadius: 2, |
| | | color: "rgba(50, 96, 225, 0.8)", |
| | | }, |
| | | symbolRepeat: false, |
| | | symbolSize: [15, 8], |
| | | symbolMargin: 1, |
| | | z: 10, |
| | | data: data, |
| | | symbolPosition: "start", |
| | | symbolOffset: [0, 3], |
| | | }, |
| | | { |
| | | barWidth: 15, |
| | | animation: false, |
| | | |
| | | type: "bar", |
| | | label: { |
| | | normal: { |
| | | color: "#fff", |
| | | show: true, |
| | | position: ["0px", "-25px"], |
| | | textStyle: { |
| | | fontSize: 14, |
| | | }, |
| | | formatter: function (a, b) { |
| | | return a.name |
| | | }, |
| | | show: true, |
| | | position: "top", |
| | | textStyle: { |
| | | color: "#ffff", |
| | | }, |
| | | }, |
| | | itemStyle: { |
| | | color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [ |
| | | { offset: 1, color: "rgba(82, 180, 249, 0.35)" }, |
| | | { offset: 0, color: "rgba(82, 180, 249, 1)" }, |
| | | ]), |
| | | }, |
| | | data: yAxis, |
| | | }, |
| | | ], |
| | | } |
| | |
| | | <style lang="less" scoped> |
| | | .file-format { |
| | | width: 100%; |
| | | height: 100%; |
| | | height: calc(100% - 30px); |
| | | } |
| | | </style> |