123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166 |
- <!-- 圆柱柱状图 -->
- <template>
- <div class="oblongBox" :style="{height:barHeight}">
- <boxTop :title="title"/>
- <div class="chartsdom" :id="id">
- </div>
- </div>
- </template>
- <script>
- import boxTop from '@/components/boxTop/index.vue'
- export default {
- data() {
- return {
- option: null,
- information: {},
- }
- },
- components: {
- boxTop,
- },
- props: {
- id: {
- type: String,
- default: ``,
- },
- barHeight: {
- type: String,
- default: `200px`,
- },
- area: {
- type: Array,
- },
- dataArray: {
- type: Array,
- },
- title: {
- type: String,
- default: ``,
- },
- unit: {
- type: String,
- },
- },
- mounted() {
- this.getEchart()
- },
- watch: {
- dataArray() {
- this.getEchart()
- },
- },
- methods: {
- getEchart() {
- let myChart = echarts.init(document.getElementById(this.id))
- let data = {
- data: [
- [92, 0, 8, 143, 89, 67, 0, 0],
- [12, 0, 8, 14, 23, 44, 0, 0],
- ],
- color: [["#00FFE3", "#4693EC"], ["#1B92FF", "#1B92FF"]],
- xAxis: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月'],
- legend: ["今年当月", "去年当月"],
- };
- let series = data.data.map((item, index) => {
- return {
- name: data.legend[index],
- type: 'bar',
- itemStyle: {
- normal: {
- color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
- {
- offset: 0,
- color: data.color[index][0]
- },
- {
- offset: 1,
- color: data.color[index][1]
- }
- ])
- }
- },
- data: data.data[index]
- }
- })
- this.option = {
- xAxis: {
- axisLabel: {
- color: '#29d0d0'
- },
- type: 'category',
- data: data.xAxis
- },
- legend: {
- show: true,
- textStyle: {
- color: '#ffffff'//字体颜色
- }
- },
- tooltip: {
- show: true,
- trigger: 'axis',
- axisPointer: {
- label: {
- show: true,
- },
- },
- },
- grid: {
- top: '15%',
- left: '5%',
- right: '5%',
- bottom: '15%',
- containLabel: true
- },
- yAxis: {
- type: 'value'
- },
- series: series
- }
- myChart.setOption(this.option, true)
- },
- },
- }
- </script>
- <style lang="less" scoped>
- .oblongBox {
- width: 460px;
- height: 216px;
- background: linear-gradient(rgba(0, 32, 77, 0.8) 0%, rgba(0, 32, 77, 0.5) 100%);
- box-shadow: inset 0px 0px 20px 0px rgba(27, 146, 255, 0.3);
- .chartsdom {
- position: relative;
- width: 100%;
- height: 90%;
- }
- .title {
- position: absolute;
- top: 20px;
- left: 30px;
- display: flex;
- align-items: center;
- .label {
- font-weight: 500;
- font-size: 16px;
- color: #FFFFFF;
- margin: 0 12px;
- }
- .value {
- font-weight: bold;
- font-size: 24px;
- background: linear-gradient(0deg, rgba(27, 146, 255, 1) 0%, rgba(255, 255, 255, 1) 50%);
- background-clip: text;
- -webkit-background-clip: text;
- -webkit-text-fill-color: transparent;
- }
- }
- }
- </style>
|