123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170 |
- function loadBlock8() {
- const block8 = echarts.init(document.getElementById("block8"), "shine");
- var colorArray = [{
- top: '#ffa800',
- bottom: 'rgba(11,42,84,.3)'
- }, {
- top: '#1ace4a',
- bottom: 'rgba(11,42,84, 0.3)'
- },
- {
- top: '#4bf3ff',
- bottom: 'rgba(11,42,84,.3)'
- }, {
- top: '#4f9aff',
- bottom: 'rgba(11,42,84,.3)'
- },
- {
- top: '#b250ff',
- bottom: 'rgba(11,42,84,.3)'
- }
- ];
- const block8Opt = {
- tooltip: {
- show: true,
- formatter: "{b}:{c}"
- },
- grid: {
- left: '6%',
- top: '0',
- right: '4%',
- bottom: '8%',
- containLabel: true
- },
- xAxis: {
- type: 'value',
- show: false,
- position: 'top',
- axisTick: {
- show: false
- },
- axisLine: {
- show: false,
- lineStyle: {
- color: '#fff',
- }
- },
- splitLine: {
- show: false
- },
- },
- yAxis: [{
- type: 'category',
- axisTick: {
- show: false,
- alignWithLabel: false,
- length: 5,
- },
- "splitLine": {
- "show": false
- },
- inverse: 'true',
- axisLine: {
- show: false,
- lineStyle: {
- color: '#fff',
- }
- },
- data: []
- }
- ],
- series: [{
- name: '重点单位场所',
- type: 'bar',
- label: {
- normal: {
- show: true,
- position: 'right',
- formatter: '{c}',
- textStyle: {
- color: 'white'
- }
- }
- },
- itemStyle: {
- normal: {
- show: true,
- color: function (params) {
- let num = colorArray.length;
- return {
- type: 'linear',
- colorStops: [{
- offset: 0,
- color: colorArray[params.dataIndex % num].bottom
- }, {
- offset: 1,
- color: colorArray[params.dataIndex % num].top
- }, {
- offset: 0,
- color: colorArray[params.dataIndex % num].bottom
- }, {
- offset: 1,
- color: colorArray[params.dataIndex % num].top
- }, {
- offset: 0,
- color: colorArray[params.dataIndex % num].bottom
- }, {
- offset: 1,
- color: colorArray[params.dataIndex % num].top
- }, {
- offset: 0,
- color: colorArray[params.dataIndex % num].bottom
- }, {
- offset: 1,
- color: colorArray[params.dataIndex % num].top
- }, {
- offset: 0,
- color: colorArray[params.dataIndex % num].bottom
- }, {
- offset: 1,
- color: colorArray[params.dataIndex % num].top
- }, {
- offset: 0,
- color: colorArray[params.dataIndex % num].bottom
- }, {
- offset: 1,
- color: colorArray[params.dataIndex % num].top
- }],
-
- }
- },
- barBorderRadius: 70,
- borderWidth: 0,
- borderColor: '#333',
- }
- },
- barGap: '0%',
- barCategoryGap: '50%',
- data: []
- }
- ]
- };
- block8.setOption(block8Opt);
- $.ajax({
- url: ajaxBaseUrl + "data/public-security.json",
- dataType: "json"
- }).done(function () {
- $("#block8").addClass("chart-done");
- }).done(function (data) {
- const yData = [];
- const seriesData = [];
- for (let i in data) {
- yData.push(data[i].name);
- seriesData.push(data[i].value);
- }
- block8.setOption({
- yAxis: {
- data: yData
- },
- series: [{
- data: seriesData
- }]
- });
- }).fail(function (jqXHR) {
- console.log("Ajax Fail: ", jqXHR.status, jqXHR.statusText);
- });
- }
|