项目作者: LeungZ9

项目描述 :
angular directive for baidu echarts
高级语言: JavaScript
项目地址: git://github.com/LeungZ9/angular-echarts-lite.git
创建时间: 2017-09-13T11:16:28Z
项目社区:https://github.com/LeungZ9/angular-echarts-lite

开源协议:MIT License

下载


Angular Echarts lite

AngularJS 1.2+ directive for baidu echarts v3

Demo (updated with every release)

Quick start

Install the library

  1. npm install --save angular-echarts-lite

Then simply include the correct file in a closing <script> tag after angularJS and echarts

  1. <script src="path/to/angular.min.js"></script>
  2. <script src="path/to/echarts.min.js"></script>
  3. <script src="node_modules/angular-echarts-lite/dist/angular-echarts-lite.min.js"></script>

Add dependency and declare a demo controller

  1. angular.module("demo", ['angular-echarts-lite'])
  2. .controller("DemoController", function () {
  3. this.config = {
  4. title: {
  5. text: '对数轴示例',
  6. left: 'center'
  7. },
  8. tooltip: {
  9. trigger: 'item',
  10. formatter: '{a} <br/>{b} : {c}'
  11. },
  12. legend: {
  13. left: 'left',
  14. data: ['3的指数']
  15. },
  16. xAxis: {
  17. type: 'category',
  18. name: 'x',
  19. splitLine: { show: false },
  20. data: ['一', '二', '三', '四', '五', '六', '七', '八', '九']
  21. },
  22. grid: {
  23. left: '3%',
  24. right: '4%',
  25. bottom: '3%',
  26. containLabel: true
  27. },
  28. yAxis: {
  29. type: 'log',
  30. name: 'y'
  31. },
  32. series: [
  33. {
  34. name: '3的指数',
  35. type: 'line',
  36. data: [1, 3, 9, 27, 81, 247, 741, 2223, 6669]
  37. }
  38. ]
  39. };
  40. })

Add this markup into page

  1. <div ng-controller="DemoController as vm">
  2. <lz-chart config="vm.config" style="width:480px;height:480px"></lz-chart>
  3. </div>

That’s all! Now you can get up and running the demo.

Use angular echarts lite with webpack

You can obtain angular echarts lite directly in project via webpack

  1. require('angular-echarts-lite')
  2. //To add dependency into your module
  3. angular.module("ur-module", ['angular-echarts-lite'])

Usage

  1. <lz-chart config= theme=? instance=? unwatch></lz-chart>

You can find all possible attributes for the directive in the table below:

Attribute Usage
config Object, set the configuration of chart by using echarts options
Here is some additional configuration:
forceClear boolean, whether to remove chart before update
notMerge boolean, whether not to merge with previous
errorMsg Object, configuration item while error, more detail
theme Object or string, set the theme of chart
instance Bind a function to get chart instance
unwatch Cancel scope watch for config and theme, just takes effort during directive init

Running the demo

Setup the repo:

  1. git clone https://github.com/LeungZ9/angular-echarts-lite.git && cd angular-echarts-lite
  2. npm i

Run the development server:

  1. cd /path/to/angular-echarts-lite
  2. npm run dev