Detailed explanation of how angularjs implements the most concise tutorial on echart chart effects, angularjsechart

Source: Internet
Author: User

Detailed explanation of how angularjs implements the most concise tutorial on echart chart effects, angularjsechart

This article describes how angularjs implements the most concise tutorial on the effect of echart charts. The details are as follows:

Ehcart is a data chart made by Baidu Based on native js. Both interfaces and configurations are easy to read and can be used for commercial use.

Echart package reference

Download and decompress the package to lib.

: Echart_jb51.rar

And reference two js files in index.html.

Reference angular-echarts in app. js

Page 2

Html page

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

Controller

/*** Created by xiehan on April /11/29. */angular. module ('studyapp. controllers '). controller ('echartctrl', function ($ scope, $ rootScope, $ ionicHistory, $ location) {$ scope. title = 'echart';/* Official instance link: http://echarts.baidu.com/examples.html */$ scope. goBack = function () {$ ionicHistory. goBack () ;}; // format $ scope for data. dataList = {incomeData: ""}; // pie chart $ scope. pieConfig ={}; // circular graph $ scope. donutConfig = {}; init (); function init () {initChartsConfig (); initIncome (); initConfigChart () ;}// initialize function initChartsConfig () {$ scope. pieConfig = {center: [120, '20140901'], radius: 90}; $ scope. donutConfig = {radius: [0, 90] };}// pie chart data function initIncome () {var temp = [{NAME: "Test 1", NUM: 11 }, {NAME: "Test 2", NUM: 22 },{ NAME: "Test 3", NUM: 33 },{ NAME: "Test 4", NUM: 44}]; if (temp) {// process data var temp2 = []; angular. forEach (temp, function (item) {var t = {x: item. NAME, y: item. NUM}; temp2.push (t) ;}); $ scope. dataList. incomeData = [{name: 'echart pie chart test', datapoints: temp2}] ;}// function initConfigChart () {var parkaccountChart = echarts. init (document. getElementById ('id0001 '); // div tag id var seriesLabel = {normal: {show: true, textBorderColor:' #333 ', textBorderWidth: 2 }}; var option = {tooltip: {trigger: 'axis ', axisPointer: {type: 'shadow'}, legend: {data: ['total 1', 'total 2 ', 'Total 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: 'total 1 ', type: 'bar', label: seriesLabel, data: [165,170,330]}, {name: 'total 2', type: 'bar', label: seriesLabel, data: [150,105,110]}, {name: 'total 3', type: 'bar', label: seriesLabel, data: [220, 82, 63]}; parkaccountChart. setOption (option );}});

The above is all the content of this article. I hope it will be helpful for your learning and support for helping customers.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.