ECharts简单使用

本文介绍了如何使用ECharts创建柱状图、饼状图、条形图和折线图,包括配置项如标题、子标题、图例、数据等,并展示了如何在ExtJS环境中集成ECharts。
摘要由CSDN通过智能技术生成









代码(ECharts工具类)

/**
 * Created by Administrator on 2017/8/16.
 */
// 柱状图
function createBarChart(widthNum, heightNum, chartId, eTitle, eSubTitle, eLegend, exAxis, eyAxis, myStore) {
    var rotate = 0;
    if (exAxis.length > 6) {
        rotate = 25;
    }
    return Ext.create('Ext.panel.Panel', {
        border: false,
        layout: {
            align: 'center',
            pack: 'center',
            type: 'vbox'
        },
        items: [
            {
                xtype: 'panel',
                align: 'center',
                html: '<div id="' + chartId + '" style="width: ' + widthNum + 'px;height: ' + heightNum + 'px"></div>',
                listeners: {
                    afterRender: function () {
                        // 初始化echarts
                        var barChart = echarts.init(document.getElementById(chartId));
                        // 显示加载
                        barChart.showLoading({
                            text: 'Loading',//显示加载中的文字
                            effect: 'spin',//加载中的显示样式
                            textStyle: {
                                fontSize: 20
                            }
                        });
                        // 指定图表的配置项和数据
                        var optionBar = {
                            // 标题
                            title: {
                                text: eTitle,
                                subtext: eSubTitle,
                                x: 'center'
                            },
                            // 提示
                            tooltip: {
                                trigger: 'axis',
                                axisPointer: {  //坐标轴指示器,坐标轴触发有效
                                    type: 'shadow' // 默认为直线,可选为'line' | 'shadow'| 'cross'
                                }
                            },
                            // 边框
                            grid: {
                                left: '3%',
                                right: '5%',
                                bottom: '9%',
                                containLabel: true
                            },
                            // 图例
                            legend: {
                                orient: 'horizontal',
                                x: 'center',
     

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值