国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > JavaScript > 正文

詳解angularjs實現echart圖表效果最簡潔教程

2019-11-19 14:49:23
字體:
來源:轉載
供稿:網友

本文介紹了詳解angularjs實現echart圖表效果最簡潔教程,分享給大家,具體如下:

ehcart是百度做的數據圖表,基于原生js。接口和配置都寫的很好很易讀,還可以用于商用。

一 echart包引用

下載解壓,放入lib中。

下載地址:echart_jb51.rar

并在index.html中引用如圖兩個js文件。

app.js中引用angular-echarts

二 頁面

html頁面

<!--餅圖-->  <div>   <donut-chart config="donutConfig" data="dataList.incomeData">   </donut-chart>  </div>
<!--柱狀圖--> <div id="id0001" style="width: 100%;height: 400px; padding: 0;margin: 0; border-width: 0; "> </div>

controller

/** * Created by xiehan on 2017/11/29. */angular.module('studyApp.controllers') .controller('EchartCtrl', function ($scope, $rootScope, $ionicHistory,$location) {  $scope.title = 'echart圖表';  /*   官方實例鏈接:http://echarts.baidu.com/examples.html   */  $scope.goBack = function () {   $ionicHistory.goBack();  };  //用于數據的格式化  $scope.dataList = {   incomeData:""  };  // 餅圖  $scope.pieConfig = {};  // 環形圖  $scope.donutConfig = {};  init();  function init() {   initChartsConfig();   initIncome();   initConfigChart();  }  //餅圖配置初始化  function initChartsConfig() {   $scope.pieConfig = {    center: [120, '50%'],    radius: 90   };   $scope.donutConfig = {    radius: [0, 90]   };  }  //餅圖數據  function initIncome(){   var temp = [    {     NAME:"測試1",     NUM:11    },    {     NAME:"測試2",     NUM:22    },    {     NAME:"測試3",     NUM:33    },    {     NAME:"測試4",     NUM:44    }   ];   if (temp) {    // 處理數據    var temp2 = [];    angular.forEach(temp, function (item) {     var t = {x: item.NAME, y: item.NUM};     temp2.push(t);    });    $scope.dataList.incomeData = [{     name: 'echart餅圖測試',     datapoints: temp2    }];   }  }  //柱狀圖數據  function initConfigChart() {   var parkaccountChart = echarts.init(document.getElementById('id0001'));//div 標簽id   var seriesLabel = {    normal: {     show: true,     textBorderColor: '#333',     textBorderWidth: 2    }   };   var option = {    tooltip: {     trigger: 'axis',     axisPointer: {      type: 'shadow'     }    },    legend: {     data: ['總數1', '總數2', '總數3'],     bottom:true    },    grid: {     left: '1%',     right: '4%',     bottom: '8%',     top:'5%',     containLabel: true    },    xAxis: {     type: 'value',     name: '',     axisLabel: {      formatter: '{value}'     }    },    yAxis: {     type: 'category',     inverse: true,     data: ['y1', 'y2', 'y3']    },    series: [     {      name: '總數1',      type: 'bar',      label: seriesLabel,      data: [165, 170, 330]     },     {      name: '總數2',      type: 'bar',      label: seriesLabel,      data: [150, 105, 110]     },     {      name: '總數3',      type: 'bar',      label: seriesLabel,      data: [220, 82, 63]     }    ]   };   parkaccountChart.setOption(option);  } });

效果圖

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持武林網。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 潼关县| 乌什县| 临海市| 丰镇市| 钟祥市| 思茅市| 汶上县| 大荔县| 庆城县| 毕节市| 乐昌市| 山丹县| 登封市| 革吉县| 贵州省| 巴里| 连江县| 汨罗市| 石首市| 新闻| 滨海县| 正蓝旗| 武平县| 腾冲县| 湖口县| 马鞍山市| 忻州市| 常熟市| 神农架林区| 蒙阴县| 临邑县| 巴林左旗| 朝阳县| 吉林省| 华阴市| 神池县| 武宁县| 金寨县| 招远市| 临高县| 广德县|