Authored by ‘superliu’

杭州-通知查询-echars 拖动条优化

@@ -422,24 +422,125 @@ layui.define(['table', 'form', 'admin', 'layer', 'common','sessions', 'xmSelect' @@ -422,24 +422,125 @@ layui.define(['table', 'form', 'admin', 'layer', 'common','sessions', 'xmSelect'
422 } 422 }
423 }], 423 }],
424 series: series, 424 series: series,
  425 + }
  426 + echartObject.setOption(option)
  427 +
  428 + }
  429 + /********************单独加载更多****************************/
  430 + function loadNoticeMoreChart(echartObject,xData,yData) {
  431 + var series = [{
  432 + name: '通知次数',
  433 + data: yData,
  434 + barWidth: 20,
  435 + type: 'bar',
  436 + label: {
  437 + show: true,
  438 + position: 'top',
  439 + textStyle: {
  440 + color: '#555'
  441 + },
  442 + },
  443 + itemStyle: {
  444 + normal: {
  445 + color: (params) => {
  446 + var colors = ['#b6c2ff', '#96edc1', '#fcb75b'];
  447 + return colors[params.dataIndex % 3]
  448 + }
  449 + }
  450 + },
  451 + emphasis: {
  452 + itemStyle: {
  453 + color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
  454 + { offset: 0, color: '#2378f7' },
  455 + { offset: 0.7, color: '#2378f7' },
  456 + { offset: 1, color: '#83bff6' }
  457 + ])
  458 + }
  459 + },
  460 + }]
  461 +
  462 + var option = {
  463 + tooltip: {
  464 + trigger: 'axis',
  465 + axisPointer: {
  466 + type: 'shadow'
  467 + }
  468 + },
  469 + grid: [{
  470 + top: 20,
  471 + bottom: 70,
  472 + left: 30,
  473 + right: 5
  474 + }],
  475 + xAxis: [{
  476 + type: 'category',
  477 + data: xData,
  478 + axisLabel: {
  479 + color: '#333',
  480 + show: true,
  481 + interval:0,
  482 + rotate:15
  483 + },
  484 + axisLine: {
  485 + lineStyle: {
  486 + color: '#e7e7e7'
  487 + }
  488 + },
  489 + axisTick: {
  490 + lineStyle: {
  491 + color: '#e7e7e7'
  492 + }
  493 + },
  494 + zlevel: 1
  495 + }],
  496 + yAxis: [{
  497 + type: 'value',
  498 + gridIndex: 0,
  499 + axisLabel: {
  500 + color: '#333'
  501 + },
  502 + splitLine: {
  503 + lineStyle: {
  504 + type: 'dashed'
  505 + }
  506 + },
  507 + axisLine: {
  508 + lineStyle: {
  509 + color: '#ccc'
  510 + }
  511 + },
  512 + axisTick: {
  513 + lineStyle: {
  514 + color: '#ccc'
  515 + }
  516 + }
  517 + }],
  518 + series: series,
425 dataZoom: [ 519 dataZoom: [
426 - {  
427 - type: 'inside' 520 + { type: 'slider',
  521 + show: true,
  522 + xAxisIndex: [0],
  523 + left: '1%',
  524 + bottom: -5,
  525 + start: 0,
  526 + end: 50 //初始化滚动条
428 } 527 }
429 ], 528 ],
430 } 529 }
431 echartObject.setOption(option) 530 echartObject.setOption(option)
432 - const zoomSize = 6;  
433 - echartObject.on('click', function (params) {  
434 - echartObject.dispatchAction({  
435 - type: 'dataZoom',  
436 - startValue: xData[Math.max(params.dataIndex - zoomSize / 2, 0)],  
437 - endValue:  
438 - xData[Math.min(params.dataIndex + zoomSize / 2, yData.length - 1)]  
439 - });  
440 - }); 531 + window.onresize=function(){
  532 + echartObject.resize();
  533 + }
  534 + // const zoomSize = 6;
  535 + // echartObject.on('click', function (params) {
  536 + // echartObject.dispatchAction({
  537 + // type: 'dataZoom',
  538 + // startValue: xData[Math.max(params.dataIndex - zoomSize / 2, 0)],
  539 + // endValue:
  540 + // xData[Math.min(params.dataIndex + zoomSize / 2, yData.length - 1)]
  541 + // });
  542 + // });
441 } 543 }
442 -  
443 //获取图表数据 544 //获取图表数据
444 function getChartData() { 545 function getChartData() {
445 var where = { 546 var where = {
@@ -522,7 +623,7 @@ layui.define(['table', 'form', 'admin', 'layer', 'common','sessions', 'xmSelect' @@ -522,7 +623,7 @@ layui.define(['table', 'form', 'admin', 'layer', 'common','sessions', 'xmSelect'
522 var yData = res.map.countList; 623 var yData = res.map.countList;
523 var xData = res.map.userList; 624 var xData = res.map.userList;
524 //展示前20条数据 @Editor LH 625 //展示前20条数据 @Editor LH
525 - loadNoticeChart(noticeTypeChartNew,xData, yData); 626 + loadNoticeMoreChart(noticeTypeChartNew,xData, yData);
526 } 627 }
527 } 628 }
528 }) 629 })
@@ -103,9 +103,9 @@ @@ -103,9 +103,9 @@
103 </article> 103 </article>
104 <!--上传弹框--> 104 <!--上传弹框-->
105 <script id="more_info" type="text/html"> 105 <script id="more_info" type="text/html">
106 - <div style="align:center;">  
107 - <div class="lay-row-title" > 人员分组统计 <div style=" float:right;"></div></div>  
108 - <div class="pie-chart" style="height: 350px" id="notice_chart_type_new"></div> 106 + <div style="align:center;padding: 20px;height: 330px">
  107 + <div class="lay-row-title" lay-tips="灰色拖动条可以左右拉缩并拖动展示其它数据"> 人员分组统计 </div>
  108 + <div class="pie-chart" style="height: 100%" id="notice_chart_type_new"></div>
109 </div> 109 </div>
110 </script> 110 </script>
111 <script> 111 <script>