123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284 |
- import ChartBar from '../../../src/chart/bar/ChartBar34/ChartBar34.js';
-
- var chart = new ChartBar(document.getElementsByClassName("chartContainer")[0], {});
- window.chart = chart;
- window.addEventListener("resize", function () {
- chart.resize();
- });
-
- window.addEventListener('elementClick', (a, b) => {
- console.log('触发', a.detail)
- });
-
- let option = {
- type: "p1",
- bg: {
- backgroundColor: '#000000'
- },
- title: {},
- tooltip: {
- bgStyle: {
- backgroundColor: 'rgba(0,0,0,0.7)',
- // borderColor:'#888e0e',
- // borderWidth:1
- },
- },
- legend: {
- left: "18%",
- top: '6%',
- itemWidth: 12,
- circleSize: 4,
- textStyle: {
- fontSize: 16,
- // color: '#50a7bd'
- }
- },
- grid: {
- left: '18%',
- top: '20%',
- right: '18%',
- bottom: '18%',
- containLabel: false,
- },
- // legend: Legend.option,
- xAxis: {
- type: "category",
- lastLabel: '总花费',
- data: ["类别一", "类别二", "类别三", "类别四", "类别五", "类别六", "类别七", "类别八", "类别六", "类别七", "类别八"],
- // min:0,
- axisLine: {
- show: false,
- lineStyle: {
- color: '#333333',
- width: 2,
- type: 'solid'
- }
- },
- axisTick: {
- show: false,
- alignWithLabel: false,
- interval: 'auto',
- length: 5,
- lineStyle: {
- color: '#333333',
- width: 1
- }
- },
- splitLine: {
- show: false,
- lineStyle: {
- color: '#333333',
- width: 1,
- type: 'solid'
- }
- },
- axisLabel: {
- show: true,
- textStyle: {
- fontSize: 14,
- color: '#bdbdbd',
- backgroundColor: 'rgba(255,255,255,0.05)',
- highlightColor: 'rgba(255,255,255,0.4)',
- }
- }
- },
- yAxis: {
- type: 'value',
- axisLine: {
- show: true,
- lineStyle: {
- color: '#333333',
- width: 2,
- type: 'solid',
- distance: 2, //偏移距离
- }
- },
- axisTick: {
- show: true,
- alignWithLabel: true,
- interval: 'auto',
- length: -4,
- lineStyle: {
- color: '#333333',
- width: 2
- }
- },
- splitLine: {
- show: true,
- lineStyle: {
- color: '#333333',
- width: 1,
- type: 'solid'
- }
- },
- axisLabel: {
- show: true,
- textStyle: {
- fontSize: 16,
- color: '#797979'
- }
- },
- bgColor: 'rgba(255,255,255,0.05)',
- },
- shape: {
- barCategoryGap: '60%',
- // barGap: '8%',
- label: {
- show: false,
- textStyle: {
- fontSize: 12,
- fontWeight: 'normal',
- color: '#00f4fe'
- },
- positionX: 5
- },
- circleSize: 5,
- },
- series: [
- {
- name: '花费',
- type: 'bar',
- data: [[220, 1450], [50, 1000], [100, 1500], [250, 1300], [450, 800], [200, 1600], [600, 1800], [580, 1300], [250, 1300], [450, 800], [200, 1600]],
- }
- ],
- color: ["#3fffa7", "#3f90ff"],
- };
- let option2 = {
- type: "p1",
- bg: {
- backgroundColor: '#000000'
- },
- title: {},
- tooltip: {
- bgStyle: {
- backgroundColor: 'rgba(0,0,0,0.7)',
- // borderColor:'#888e0e',
- // borderWidth:1
- },
- },
- legend: {
- left: "18%",
- top: '6%',
- itemWidth: 12,
- circleSize: 4,
- textStyle: {
- fontSize: 16,
- // color: '#50a7bd'
- }
- },
- grid: {
- left: '18%',
- top: '20%',
- right: '18%',
- bottom: '18%',
- containLabel: false,
- },
- // legend: Legend.option,
- xAxis: {
- type: "category",
- lastLabel: '总花费',
- data: ["类别一", "类别二", "类别三"],
- // min:0,
- axisLine: {
- show: false,
- lineStyle: {
- color: '#333333',
- width: 2,
- type: 'solid'
- }
- },
- axisTick: {
- show: false,
- alignWithLabel: false,
- interval: 'auto',
- length: 5,
- lineStyle: {
- color: '#333333',
- width: 1
- }
- },
- splitLine: {
- show: false,
- lineStyle: {
- color: '#333333',
- width: 1,
- type: 'solid'
- }
- },
- axisLabel: {
- show: true,
- textStyle: {
- fontSize: 14,
- color: '#bdbdbd',
- backgroundColor: 'rgba(255,255,255,0.05)',
- highlightColor: 'rgba(255,255,255,0.4)',
- }
- }
- },
- yAxis: {
- type: 'value',
- axisLine: {
- show: true,
- lineStyle: {
- color: '#333333',
- width: 2,
- type: 'solid',
- distance: 2, //偏移距离
- }
- },
- axisTick: {
- show: true,
- alignWithLabel: true,
- interval: 'auto',
- length: -4,
- lineStyle: {
- color: '#333333',
- width: 2
- }
- },
- splitLine: {
- show: true,
- lineStyle: {
- color: '#333333',
- width: 1,
- type: 'solid'
- }
- },
- axisLabel: {
- show: true,
- textStyle: {
- fontSize: 16,
- color: '#797979'
- }
- },
- bgColor: 'rgba(255,255,255,0.05)',
- },
- shape: {
- barCategoryGap: '60%',
- // barGap: '8%',
- label: {
- show: false,
- textStyle: {
- fontSize: 12,
- fontWeight: 'normal',
- color: '#00f4fe'
- },
- positionX: 5
- },
- circleSize: 5,
- },
- series: [
- {
- name: '花费',
- type: 'bar',
- data: [[220, 1450], [50, 1000], [100, 1500]],
- }
- ],
- color: ["#3fffa7", "#3f90ff"],
- };
- // setTimeout(() => {
- // chart.setOption(option2)
- // }, 2000)
- // setTimeout(() => {
- // chart.setOption(option)
- // }, 4000)
|