├── .gitignore ├── Gruntfile.js ├── README.md ├── angualr-echarts.js ├── angular-echarts.min.js ├── bower.json ├── example └── index.html ├── grunt ├── uglify.js └── watch.js └── package.json /.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | node_modules 3 | bower_components -------------------------------------------------------------------------------- /Gruntfile.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by 烬云 on 2014/9/13. 3 | */ 4 | module.exports = function (grunt) { 5 | var path = require('path'); 6 | 7 | require('load-grunt-config')(grunt, { 8 | // path to task.js files, defaults to grunt dir 9 | configPath: path.join(process.cwd(), 'grunt'), 10 | 11 | // auto grunt.initConfig 12 | init: true, 13 | 14 | // data passed into config. Can use with <%= test %> 15 | data: { 16 | jsTarget: 'dist' 17 | }, 18 | 19 | // can optionally pass options to load-grunt-tasks. 20 | // If you set to false, it will disable auto loading tasks. 21 | loadGruntTasks: { 22 | pattern: 'grunt-*', 23 | config: require('./package.json'), 24 | scope: 'devDependencies' 25 | }, 26 | 27 | //can post process config object before it gets passed to grunt 28 | postProcess: function (config) { 29 | } 30 | }); 31 | 32 | grunt.registerTask('default', ['uglify']); 33 | }; 34 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | angular-echarts 2 | =============== 3 | 4 | angular warp for echarts 5 | -------------------------------------------------------------------------------- /angualr-echarts.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by Administrator on 2014/10/28. 3 | */ 4 | angular.module('ngEcharts', []) 5 | .factory('$echartsConfig', [function () { 6 | return {} 7 | }]) 8 | //.factory('$echartsInstance', [function () { 9 | // var instance = {}; 10 | // instance.getById = function (id) { 11 | // return instance[id]; 12 | // }; 13 | // return instance; 14 | //}]) 15 | .directive('echarts', ['$echartsConfig', function ($echartsConfig) { 16 | return { 17 | link: function (scope, element, attrs) { 18 | if (!scope.$echartsInstance)scope.$echartsInstance = {}; 19 | scope.$watch(attrs.echarts, function () { 20 | var option = angular.extend($echartsConfig, scope.$eval(attrs.echarts)); 21 | if (option.id) { 22 | scope.$echartsInstance[option.id] = echarts.init(element[0]); 23 | scope.$echartsInstance[option.id].setOption(option); 24 | } else { 25 | scope.$echartsInstance = echarts.init(element[0]); 26 | scope.$echartsInstance.setOption(option); 27 | } 28 | }) 29 | } 30 | }; 31 | }]); -------------------------------------------------------------------------------- /angular-echarts.min.js: -------------------------------------------------------------------------------- 1 | /*! angular-echarts 29-10-2014 */ 2 | angular.module("ngEcharts",[]).factory("$echartsConfig",[function(){return{}}]).directive("echarts",["$echartsConfig",function(a){return{link:function(b,c,d){b.$echartsInstance||(b.$echartsInstance={}),b.$watch(d.echarts,function(){var e=angular.extend(a,b.$eval(d.echarts));e.id?(b.$echartsInstance[e.id]=echarts.init(c[0]),b.$echartsInstance[e.id].setOption(e)):(b.$echartsInstance=echarts.init(c[0]),b.$echartsInstance.setOption(e))})}}}]); -------------------------------------------------------------------------------- /bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "angular-echarts", 3 | "version": "0.0.1", 4 | "homepage": "https://github.com/violet-day/angular-echarts", 5 | "authors": [ 6 | "violet-day " 7 | ], 8 | "keywords": [ 9 | "angular", 10 | "echarts" 11 | ], 12 | "license": "MIT", 13 | "ignore": [ 14 | "**/.*", 15 | "node_modules", 16 | "bower_components", 17 | "test", 18 | "tests" 19 | ], 20 | "dependencies": { 21 | "angular": "*", 22 | "echarts":"2.0.0" 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /example/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | 47 | 48 | 49 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /grunt/uglify.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by 烬云 on 2014/10/21. 3 | */ 4 | module.exports = { 5 | options: { 6 | //生成一个banner注释并插入到输出文件的顶部 7 | banner: '/*! <%= package.name %> <%= grunt.template.today("dd-mm-yyyy") %> */\n' 8 | }, 9 | generated: { 10 | files: { 11 | 'angular-echarts.min.js': ['angualr-echarts.js'] 12 | } 13 | } 14 | }; 15 | -------------------------------------------------------------------------------- /grunt/watch.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Created by 烬云 on 2014/10/21. 3 | */ 4 | module.exports = { 5 | files: ['angualr-echarts.js'], 6 | tasks: ['uglify'] 7 | }; -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "angular-echarts", 3 | "version": "1.0.0", 4 | "description": "angular-echarts", 5 | "main": "Gruntfile.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "repository": { 10 | "type": "git", 11 | "url": "https://github.com/violet-day/angular-echarts" 12 | }, 13 | "author": "Nemo", 14 | "license": "ISC", 15 | "bugs": { 16 | "url": "https://github.com/violet-day/angular-echarts/issues" 17 | }, 18 | "homepage": "https://github.com/violet-day/angular-echarts", 19 | "devDependencies": { 20 | "grunt": "^0.4.5", 21 | "grunt-contrib-uglify": "^0.6.0", 22 | "grunt-contrib-watch": "^0.6.1", 23 | "load-grunt-config": "^0.14.0", 24 | "load-grunt-tasks": "^0.6.0" 25 | } 26 | } 27 | --------------------------------------------------------------------------------