| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117 |
- //判断用户是否购买app设备
- if (sessionStorage.getItem('purchase') == 'yes' || sessionStorage.getItem('purchase') == 'admin') {
- //图标的数据
- var staff = new Array() //测报员
- var insectA = new Array() //虫害
- var plantA = new Array() //病害
- function a() {
- $.ajax({
- url: 'line_chart',
- type: 'get',
- data: {
- ret: '2'
- },
- dataType: 'json',
- success: function (data) {
- staff.push('product')
- insectA.push('虫害')
- plantA.push('病害')
- for (var i = 0; i < data.length; i++) {
- var name = data[i].name
- var plant = data[i].cby_plant
- var insect = data[i].cby_insect
- staff.push(name)
- plantA.push(plant)
- insectA.push(insect)
- }
- show(staff, insectA, plantA)
- },
- error: function (error) {
- console.log(error)
- }
- })
- }
- a()
- function show (s, i, p) {
- var dom = document.getElementById("main");
- var myChart = echarts.init(dom);
- var app = {};
- option = null;
- option = {
- legend: {},
- tooltip: {
- trigger: 'axis',
- showContent: true,
- },
- dataset: {
- source: [
- s, i, p
- ]
- },
- xAxis: {
- type: 'category'
- },
- yAxis: {
- gridIndex: 0
- },
- grid: {
- top: '20%',
- right: "36%",
- },
- series: [{
- type: 'bar',
- stack: '总量',
- smooth: true,
- seriesLayoutBy: 'row'
- },
- {
- type: 'bar',
- smooth: true,
- stack: '总量',
- seriesLayoutBy: 'row'
- },
- {
- type: 'pie',
- id: 'pie',
- radius: '40%',
- center: ['86%', '50%'],
- label: {
- formatter: '{b}: {@2012} ({d}%)'
- },
- encode: {
- itemName: 'product',
- value: '2012',
- tooltip: '2012'
- }
- }
- ]
- };
- myChart.on('updateAxisPointer', function (event) {
- var xAxisInfo = event.axesInfo[0];
- if (xAxisInfo) {
- var dimension = xAxisInfo.value + 1;
- myChart.setOption({
- series: {
- id: 'pie',
- label: {
- formatter: '{b}: {@[' + dimension + ']} ({d}%)'
- },
- encode: {
- value: dimension,
- tooltip: dimension
- }
- }
- });
- }
- });
- myChart.setOption(option);
- if (option && typeof option === "object") {
- myChart.setOption(option, true);
- }
- // console.log(option.dataset.source)
- }
- } else if (sessionStorage.getItem('purchase') == 'no') {
- alert('未购买设备')
- }
|