echarts icon indicating copy to clipboard operation
echarts copied to clipboard

大数据示例在官网,和在本地运行,速度差异较大

Open shamoq opened this issue 10 years ago • 2 comments

问题简述 (One-line summary)

大数据量的问题,在官网上找到一个示例:http://echarts.baidu.com/demo.html#area-simple 无论用ie查看,还是谷歌查看,都是非常快。 但是项目中仅仅有7000条数据,一个y轴数据,调用setOption就花了 4秒。 好奇为什么百度官网那么快,而我本地如此慢。

版本及环境 (Version & Environment)

  • ECharts 版本 (ECharts version):3.0
  • 浏览器类型和版本 (Browser version): ie10
  • 操作系统类型和版本 (OS Version): win7 sp1

重现步骤 (Steps to reproduce)

1.打开http://echarts.baidu.com/gallery/editor.html?c=area-simple ,将网页极其内容全部保存到本地。 2.使用windows IIS作为服务器,运行保存后的网页 。 3.打开http://echarts.baidu.com/demo.html#area-simple,赋值左侧的代码到本地运行的网页里。 4.点击运行。 5.发现加载图表渲染时间为4秒。而对比官网同样的示例,渲染只有369毫秒。 浏览器模式:IE10 文档模式:标准

期望结果 (Expected behaviour)

同样的代码配置,希望和百度官网示例运行速度差不多。

可能哪里有问题 (What went wrong)

暂时无法猜测。因为第一次尝试的时候,我直接将官网提供的option拷贝到本地,发现速度差异较大,后来直接将网页另存为到本地,发现差异依旧较大。

ECharts配置项 (ECharts option)

var base = +new Date(1968, 9, 3);
var oneDay = 24 * 3600 * 1000;
var date = [];

var data = [Math.random() * 300];

for (var i = 1; i < 20000; i++) {
    var now = new Date(base += oneDay);
    date.push([now.getFullYear(), now.getMonth() + 1, now.getDate()].join('/'));
    data.push(Math.round((Math.random() - 0.5) * 20 + data[i - 1]));
}

option = {
    tooltip: {
        trigger: 'axis',
        position: function (pt) {
            return [pt[0], '10%'];
        }
    },
    title: {
        left: 'center',
        text: '大数据量面积图',
    },
    legend: {
        top: 'bottom',
        data:['意向']
    },
    toolbox: {
        feature: {
            dataZoom: {
                yAxisIndex: 'none'
            },
            restore: {},
            saveAsImage: {}
        }
    },
    xAxis: {
        type: 'category',
        boundaryGap: false,
        data: date
    },
    yAxis: {
        type: 'value',
        boundaryGap: [0, '100%']
    },
    dataZoom: [{
        type: 'inside',
        start: 0,
        end: 10
    }, {
        start: 0,
        end: 10,
        handleIcon: 'M10.7,11.9v-1.3H9.3v1.3c-4.9,0.3-8.8,4.4-8.8,9.4c0,5,3.9,9.1,8.8,9.4v1.3h1.3v-1.3c4.9-0.3,8.8-4.4,8.8-9.4C19.5,16.3,15.6,12.2,10.7,11.9z M13.3,24.4H6.7V23h6.6V24.4z M13.3,19.6H6.7v-1.4h6.6V19.6z',
        handleSize: '80%',
        handleStyle: {
            color: '#fff',
            shadowBlur: 3,
            shadowColor: 'rgba(0, 0, 0, 0.6)',
            shadowOffsetX: 2,
            shadowOffsetY: 2
        }
    }],
    series: [
        {
            name:'模拟数据',
            type:'line',
            smooth:true,
            symbol: 'none',
            sampling: 'average',
            itemStyle: {
                normal: {
                    color: 'rgb(255, 70, 131)'
                }
            },
            areaStyle: {
                normal: {
                    color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
                        offset: 0,
                        color: 'rgb(255, 158, 68)'
                    }, {
                        offset: 1,
                        color: 'rgb(255, 70, 131)'
                    }])
                }
            },
            data: data
        }
    ]
};


其他信息 (Other comments)

http://images.cnblogs.com/cnblogs_com/codealone/471385/o_%e6%9c%ac%e5%9c%b0%e7%a4%ba%e4%be%8b.jpg http://images.cnblogs.com/cnblogs_com/codealone/471385/o_%e7%99%be%e5%ba%a6%e7%a4%ba%e4%be%8b.jpg

shamoq avatar Oct 07 '16 03:10 shamoq

你的本地 echarts 版本是?

pissang avatar Oct 08 '16 02:10 pissang

echarts3.0 http://echarts.baidu.com/download.html 分别试了常用,精简,和源代码版本

shamoq avatar Oct 08 '16 03:10 shamoq