Code Monkey home page Code Monkey logo

angular-echarts's Introduction

eCharts + AngularJS

AngularJS directives to use eCharts

Prerequisites

You will need the following things properly installed on your computer.

Breaking Changes in V1

  • echart support is v3.4.0;
  • angular support is v1.6.2;
  • map chart requires additional work, see below;
  • custome themes are removed, all uses the build in ones;

Building

  • Preparing bower install & npm install

  • default gulp

develop with realtime monitor, automatic open browser to view example

  • build gulp build

Build file to dist

  • publish gulp publish

Build & bump npm versions

Usage

Install bower dependency and save for production

$ bower install angular-echarts --save

Inject echarts and angular-echarts file into page

<script src="path/to/bower_components/echarts/dist/echarts.js"></script>
<script src="path/to/bower_components/angular-echarts/dist/angular-echarts.min.js"></script>

Download and inject map definitions if you want a map chart: http://echarts.baidu.com/download-map.html

Add dependency and declare a demo controller

var app = angular.module('demo', ['angular-echarts']);
app.controller('LineChartController', function ($scope) {

    var pageload = {
        name: 'page.load',
        datapoints: [
            { x: 2001, y: 1012 },
            { x: 2002, y: 1023 },
            { x: 2003, y: 1045 },
            { x: 2004, y: 1062 },
            { x: 2005, y: 1032 },
            { x: 2006, y: 1040 },
            { x: 2007, y: 1023 },
            { x: 2008, y: 1090 },
            { x: 2009, y: 1012 },
            { x: 2010, y: 1012 },
        ]
    };

    var firstPaint = {
        name: 'page.firstPaint',
        datapoints: [
            { x: 2001, y: 22 },
            { x: 2002, y: 13 },
            { x: 2003, y: 35 },
            { x: 2004, y: 52 },
            { x: 2005, y: 32 },
            { x: 2006, y: 40 },
            { x: 2007, y: 63 },
            { x: 2008, y: 80 },
            { x: 2009, y: 20 },
            { x: 2010, y: 25 },
        ]
    };

    $scope.config = {
        title: 'Line Chart',
        subtitle: 'Line Chart Subtitle',
        debug: true,
        showXAxis: true,
        showYAxis: true,
        showLegend: true,
        stack: false,
    };

    $scope.data = [ pageload ];
    $scope.multiple = [pageload, firstPaint ];

});

Use this markup for a quick demo

<div class="col-md-3" ng-controller="LineChartController">
    <line-chart config="config" data="data"></line-chart>
    <line-chart config="config" data="multiple"></line-chart>
</div>

Contribute

  • git clone [email protected]:wangshijun/angular-echarts.git
  • change into the new directory
  • npm install
  • bower install

Running / Development

  • open docs/index.html in browser

Or you can use gulp server and visit http://localhost:8080 in Chrome browser, to avoid XMLHttpRequest Cross origin requests error.

angular-echarts's People

Contributors

huguangju avatar kerwin612 avatar neozhangthe1 avatar ohom avatar shenchenxh avatar wangsha avatar wangshijun avatar wwgc avatar zamudio-fabian avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

angular-echarts's Issues

哪里有使用文档?

没有找到使用文档啊,只有简单的几个样例。哪里有比较完整的文档吗?
样例里面的配置太少了啊。。

数组绑定chartdata的时候出问题

注释部分为数组,注释下为变量。 每次用过数组绑定,通过ng-repeat生成多个line graphs,跑着跑着,浏览器崩溃。


angular.module('nmsRealtime', ['angular-echarts'])
.controller('nmsRealtimeCtrl',
['$scope', '$interval', 'nmsRealtimeService',
function($scope, $interval, nmsRealtimeService) {
/*
$scope.chartconfigarray = [
compose_config_data('test', 'some test1..'),
compose_config_data('test', 'some test2..')
];
*/
$scope.chartconfig1 = compose_config_data('test', 'some tests..');
$scope.chartconfig2 = compose_config_data('test', 'some tests..');

     $interval(function() {
        // $scope.chartdataarray = null;
        $scope.chartdata1 = null;
        $scope.chartdata2 = null;

        var rx_dp_array = [];
        var tx_dp_array = [];

        for (var i = 0; i < DP_SIZE; ++i) {
           rx_dp_array.push({x: i, y: Math.random() * 300 });
           tx_dp_array.push({x: i, y: Math.random() * 300 });
        }

        /*
        $scope.chartdataarray = [
              [{name: 'rxpkts/s', datapoints: rx_dp_array }],
              [{name: 'txpkts/s', datapoints: tx_dp_array }]
                           ];
        */

        $scope.chartdata1 = 
            [{name: 'rxpkts/s', datapoints: rx_dp_array }];
        $scope.chartdata2 = 
            [{name: 'txpkts/s', datapoints: tx_dp_array }];
     }, 20 * 1000);
  }])

Angular 2

Hello,
Are there examples with angularjs 2?

关系图 Graph

angular-echarts 支持 Echarts 的所有图表类型吗?
按照 Usage 给的示例并没有画出关系图(Graph),是因为 angular-echarts 只支持示例里的图表类型吗?

能否将angular-echarts依赖的angularjs升级angular1.3到1.5.x

希望angular-echarts还会继承维护。
但是鉴于作者更新不太即时,有几个月没有更新了,有许多功能在angular1.5.x基本不能用了。
本人希望有这样想法的人一起做基于angularjs-1.5.x的angular-echarts版本。大概两个月内主要做这件事情,期望有一样想法的人和我联系[email protected]

Unable to change graph colour

Unable to change colour of graphs from the default one by passing the colour array as options.
Started working after adding color:config.color in this block. Can you please add this option and push an update for everyone to use?

var options = {
title: util.getTitle(data, config, type),
tooltip: util.getTooltip(data, config, type),
legend: util.getLegend(data, config, type),
toolbox: angular.extend({ show: false }, angular.isObject(config.toolbox) ? config.toolbox : {}),
xAxis: util.isHeatmapChart(type) ? config.xAxis : [ angular.extend(xAxis, util.getAxisTicks(data, config, type)) ],
yAxis: util.isHeatmapChart(type) ? config.yAxis : [ yAxis ],
graphic: config.graphic && (angular.isObject(config.graphic) || angular.isArray(config.graphic)) ? config.graphic : [],
series: util.getSeries(data, config, type),
visualMap: config.visualMap ? config.visualMap : null,
color:config.color
};

是否可以向指令中传入promise回调函数,用以异步处理图表数据

这里的代码(https://github.com/wangshijun/angular-echarts/blob/master/src/directive.js#L151-L173)是直接用data来传递请求url来做的,硬编码了对响应数据的处理,也就限制了后端必须这么返回数据,不现实。

我觉得应该提供多一些灵活性,提供回调,把数据处理放在调用端,指令中用异步回调,使用已处理好的数据。毕竟图表种类这么多,假如有多条折线,每条折线要发一次请求,这个如何处理?

我angular不是很熟,没能实现这个想法,你有何高见?

力导向图问题

力导向图中怎么实现带箭头和不带箭头连接线同时存在?

map function can not work

RT

        var itemStyle = {
            normal:{label:{
                show:true,
                formatter:'{b}',
                textStyle: {fontSize: 20,fontWeight : 'bold'}
            }},
            emphasis:{label:{show:true}}
        };
        vm.configMap = {
            title: {
                text: '某站点用户访问来源',
                subtext: '纯属虚构',
                x: 'center'
            },
            mapType: '四川|绵阳市',
            selectedMode : 'multiple',
            itemStyle: itemStyle,
            showLegend: true
        };
        vm.mapData = [{
            name: '全国344个主要城市(县)地图',
            type: 'map',
            mapType: '四川|绵阳市',
            selectedMode : 'multiple',
            itemStyle: itemStyle,
            data: [{name : '绵阳市', value : 8227}]
        }];
    <div style="width:400px; height:400px;">
        <map-chart config="test.configMap" data="test.mapData"></map-chart>
    </div>

image
it show china map not mianyang map.
so, how to set it?

echarts 3.0

Hi,

When will you release echarts 3.0 support

图表数据更新

怎么更新图表的数据,有API吗?还是自动检测,以前用的echarts3.0,$echarts下面有更新的方法,这个应该怎么更新图表数据

Does it work with eCharts 3?

Hi, thanks for building this amazing directive!

Can you specify the eCharts version that angular-echarts require?

Does it works with 3.x? or just work with 2.x?

Thanks!

bower.json 缺少 main 参数

请在 bower.json 里加入 main 参数,比如:

 "main":"./dist/angular-echarts.js",

用于指明哪个是主文件。
因为某些工具自动引入依赖,靠的就是这个参数

分享出去?

你好,这是angularjs的echarts?完善了吗,正在使用?我是否可分享出去:)

不起作用

您好,我按照Usage操作,不起作用,没有画出图,您能不能给出一个使用的项目示例,下面这两个分别怎么放置,项目结构是怎样的?

var app = angular.module('demo', ['angular-echarts']);
app.controller('LineChartController', function ($scope) {

var pageload = {
    name: 'page.load',
    datapoints: [
        { x: 2001, y: 1012 },
        { x: 2002, y: 1023 },
        { x: 2003, y: 1045 },
        { x: 2004, y: 1062 },
        { x: 2005, y: 1032 },
        { x: 2006, y: 1040 },
        { x: 2007, y: 1023 },
        { x: 2008, y: 1090 },
        { x: 2009, y: 1012 },
        { x: 2010, y: 1012 },
    ]
};

var firstPaint = {
    name: 'page.firstPaint',
    datapoints: [
        { x: 2001, y: 22 },
        { x: 2002, y: 13 },
        { x: 2003, y: 35 },
        { x: 2004, y: 52 },
        { x: 2005, y: 32 },
        { x: 2006, y: 40 },
        { x: 2007, y: 63 },
        { x: 2008, y: 80 },
        { x: 2009, y: 20 },
        { x: 2010, y: 25 },
    ]
};

$scope.config = {
    title: 'Line Chart',
    subtitle: 'Line Chart Subtitle',
    debug: true,
    showXAxis: true,
    showYAxis: true,
    showLegend: true,
    stack: false,
};

$scope.data = [ pageload ];
$scope.multiple = [pageload, firstPaint ];

});

谢谢

pie-chart NaN% Error

pie-chart
我按照README.md中步骤,只是将line换为了pie,什么原因导致这个错误?

建议:使API从echarts平滑过渡

刚使用这个指令的时候还是比较困惑的,本以为除了指令本身,它的配置项基本应与echarts一致的,但是并不是这样,这个指令又重新定义了上层API,使用的时候不得查看源码,对比echarts官网API在其中对应的位置,要考虑某个参数到底是不是本来的用意。

其实官网给出的使用结构还是一目了然的:

var option = {
    legend: {                                   // 图例配置
        padding: 5,                             // 图例内边距,单位px,默认上下左右内边距为5
        itemGap: 10,                            // Legend各个item之间的间隔,横向布局时为水平间隔,纵向布局时为纵向间隔
        data: ['ios', 'android']
    },
    tooltip: {                                  // 气泡提示配置
        trigger: 'item',                        // 触发类型,默认数据触发,可选为:'axis'
    },
    xAxis: [                                    // 直角坐标系中横轴数组
        {
            type: 'category',                   // 坐标轴类型,横轴默认为类目轴,数值轴则参考yAxis说明
            data: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
        }
    ],
    yAxis: [                                    // 直角坐标系中纵轴数组
        {
            type: 'value',                      // 坐标轴类型,纵轴默认为数值轴,类目轴则参考xAxis说明
            boundaryGap: [0.1, 0.1],            // 坐标轴两端空白策略,数组内数值代表百分比
            splitNumber: 4                      // 数值轴用,分割段数,默认为5
        }
    ],
    series: [
        {
            name: 'ios',                        // 系列名称
            type: 'line',                       // 图表类型,折线图line、散点图scatter、柱状图bar、饼图pie、雷达图radar
            data: [112, 23, 45, 56, 233, 343, 454, 89, 343, 123, 45, 123]
        },
        {
            name: 'android',                    // 系列名称
            type: 'line',                       // 图表类型,折线图line、散点图scatter、柱状图bar、饼图pie、雷达图radar
            data: [45, 123, 145, 526, 233, 343, 44, 829, 33, 123, 45, 13]
        }
    ]
};
myChart.setOption(option);

即:1. 定义option; 2. 设置option
如非echarts API中的属性,不建议放在option中,可另开一个属性,如config, 专门来配置自定义的属性。

<line-chart option="option" config="config"></line-chart>

xAxis和series中的data,处理方式建议:#14

即使封装、简化,也建议不要有对使用方式的太大改变。这样使用起来会更得心应手一些吧。

Dependency on angular ~1.3 warranted ?

In bower.json - I see a dependency on angular 1.3 .
"angular": "~1.3",

I am using angular 1.5.9 and things look ok to me. Is there a reason for the 1.3 dependency or can it be broadly 1.3+ , as in :

"angular": ">=1.3",

Any thoughts ?

用 type:'bar' 来代替 <bar-chart> 比较好

  1. 有可能同一个 data,然后渲染的时候改变 type,这样比较好
  2. 比较统一,比如都命名叫做 echart-ng 之类的,不容易写错。
  3. 跟 echart 官方的写法统一, 写在 config 里。

另外,我之前在官方 repo 里提了一个 issue: apache/echarts#2519
感觉还是很需要 angular-echarts 的

显示很乱

不知道是不是我打开有问题,我这里的横、纵坐标,还有标题,提示标签全都画到折线图里面去了。我使用的是docs/index.html.

npm bower latest version inconsistency (0.3.5 vs 0.3.6)

Tried to install angular-echarts through bower for 0.3.6 .

bower angular-echarts#0.3.6 ENORESTARGET No tag found that was able to satisfy 0.3.6

Additional error details:
Available versions in https://github.com/wangshijun/angular-echarts.git: 0.3.5, 0.3.4, 0.3.3, 0.3.2, 0.3.1, 0.3.0, 0.2.2, 0.2.1, 0.2.0, 0.2.0, 0.1.26, 0.1.25, 0.1.21, 0.1.20, 0.1.19, 0.1.18, 0.1.17, 0.1.16, 0.1.15, 0.1.14, 0.1.13, 0.1.12, 0.1.11, 0.1.10, 0.1.9, 0.1.8, 0.1.7, 0.1.6, 0.1.5, 0.1.4, 0.1.3, 0.1.2, 0.1.1, 0.0.7, 0.0.6, 0.0.5, 0.0.4, 0.0.3, 0.0.2, 0.0.1

Aliter: the latest version on npm seems to 0.3.6 though.

https://www.npmjs.com/package/angular-echarts .

It would be great to have the latest version consistently in either of them though. Thanks !

Dynamic data updates

How can I make use of the function addData to dynamically add more elements to my data source (array)?

画双轴条形图时,xAxisIndex设置后无效

你好,非常感谢你提供的angular整合echarts的方案和实现。

目前我在画横向双轴条形图的时候,遇到了设置xAxisIndex=1后不起作用的问题,请问如何解决?

在别的场景下使用yAxisIndex不存在这样的问题。

横纵坐标轴交换的场景不适用

config/data这样的封装是不错的,却无法做横纵坐标轴交换

我需要的插入的配置为

    xAxis: {
        type: 'value',
    },
    yAxis: {
        type: 'category',
    },

Dependency on echarts 2.2.7 warranted

bower.json contains this:
"echarts": "~2.2.7"
indicating this directive is compatible with the minor versions.

I am using echarts 3.4.0 though and things seem ok. So - is this compatibility on minor versions warranted or any known incompatibility issues with echarts 3.x that prevents it from being:
"echarts": ">=2.2.7"

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.