Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

图片保存时出现错误 #659

Closed
Metoyo opened this issue Sep 10, 2014 · 5 comments
Closed

图片保存时出现错误 #659

Metoyo opened this issue Sep 10, 2014 · 5 comments
Labels

Comments

@Metoyo
Copy link

Metoyo commented Sep 10, 2014

当我点击保存图片是出现以下错误:
错我信息:
Uncaught TypeError: Cannot read property 'mod' of null,
c.refreshShapes
updatePainter
(anonymous function)

错误信息位置:
echarts-plain.js:35

我的html代码:
qq20140910-1 2x

我的js代码(用的是angularjs):

        /**
         * 统计函数,饼图加柱状图
         */
        var chartFunPieAndBar = function(cont1, cont2){
          var myChart = cont1,
            myChart2 = cont2;
          var option = {
              title : {
                text : '分数详情统计',
                subtext : '',
                x : 'center'
              },
              tooltip : {
                trigger : 'item',
                formatter : "{a} <br/>{b} : {c} ({d}%)"
              },
              legend : {
                orient : 'vertical',
                x : 'left',
                data : ['不及格', '及格', '良', '优']
              },
              calculable : true,
              series : [{
                name : '成绩等级',
                type : 'pie',
                radius : '55%',
                center: ['50%', '60%'],
                data : studentPieData
              }]
            },
            option2 = {
              tooltip : {
                trigger : 'axis',
                axisPointer : {
                  type : 'shadow'
                }
              },
              legend : {
                data : ['此分数区间的人数']
              },
              toolbox : {
                show : true,
                orient : 'vertical',
                y : 'center',
                feature : {
                  mark : {
                    show : true
                  },
                  magicType : {
                    show : true,
                    type : ['line', 'bar', 'stack', 'tiled']
                  },
                  restore : {
                    show : true
                  },
                  saveAsImage : {
                    show : true
                  }
                }
              },
              calculable : true,
              xAxis : [{
                type : 'category',
                data : ['60', '60-79', '80-89', '90-100']
              }],
              yAxis : [{
                type : 'value',
                splitArea : {
                  show : true
                }
              }],
              grid : {
                x2 : 40
              },
              series : [{
                name : '此分数区间的人数',
                type : 'bar',
                stack : '总量',
                data : studentBarData
              }]
            };
          myChart.setOption(option);
          myChart2.setOption(option2);
          myChart.connect(myChart2);
          myChart2.connect(myChart);
          $timeout(function (){
            window.onresize = function () {
              myChart.resize();
              myChart2.resize();
            }
          },200);
        };
    /**
     * 分数统计,chart形状
     */
    $scope.showScoreChart = function(){
      $scope.tjSubTpl = 'views/partials/tj_chart_score.html';
      var cont1, cont2,
        addActiveFun = function() {
          cont1 = echarts.init(document.getElementById('score1'));
          cont2 = echarts.init(document.getElementById('score2'));
          chartFunPieAndBar(cont1, cont2);
        };
      $timeout(addActiveFun, 500);
    };

还有,当我用require(zrender/shape/Text)时,总是报unexpected:"_",以上是我使用过程中遇到的问题,谢谢解答。

@kener
Copy link
Contributor

kener commented Sep 10, 2014

什么版本?更新试试?

@RobinzZH
Copy link

同样发现保存图片时失败或报错,官网例子页面的混搭多图联动可以重现;
http://echarts.baidu.com/doc/example/mix9.html#macarons
在Firefox下面无错误信息,但导出图片为空白。
在Chrome下报错
Uncaught TypeError: Cannot read property 'mod' of null ----- echarts.js:29
c.refreshShapes ----- echarts.js:29
updatePainter ----- echarts.js:29
(anonymous function) ----- echarts.js:29

@kener
Copy link
Contributor

kener commented Sep 22, 2014

谢谢反馈

@kener kener added the bug label Sep 22, 2014
@kener
Copy link
Contributor

kener commented Sep 23, 2014

fixed

@kener kener closed this as completed Sep 23, 2014
@Shu-Ji
Copy link

Shu-Ji commented Nov 4, 2014

问题似乎还是存在呢?点击保存图片的时候产生的,不过点击之后图片却能显示出来,也可以单击保存,但是控制台会偶尔报错(有时又不会)。

同样使用的是angularjs动态生成的图表。(echarts-2.0.3)

pv = {}  # save all pv data
pv_chart = DigEchartsResizeService.makeResizableChart('#chart-pv')
# 经测试这里用pv_chart = ec.init($('#chart-pv')[0])也是一样的错误

default_option =
    title:
        x: 'left'
        y: 'top'
    tooltip:
        trigger: 'axis'
    legend:
        data: []
    toolbox:
        show: true,
        orient: 'vertical'
        y: 'center'
        feature:
            mark:
                show: false
            dataView:
                show: true
                readOnly: false
            magicType:
                show: true
                type: ['line', 'bar', 'stack', 'tiled']
            dataZoom:
                show: true
            restore:
                show: true
            saveAsImage:
                show: true
    calculable: true
    xAxis: [
        {
            type: 'category'
            data: ("#{i}" for i in _.range(0, 24))
        }
    ]
    yAxis: [
        {
            type: 'value'
            splitArea:
                show: true
        }
    ]
    series: []

renderChart = (pv, chart, title) ->
    option = angular.copy(default_option)
    option.title.text = title

    for k in _.sortBy(_.keys(pv))
        v = pv[k]
        option.legend.data.push(k)
        option.series.push(
            name: legend
            data: v.data
            type: 'line'
        )

    chart.setOption(option, true)  # not_merge is true


$scope.query = (data) ->
    data.action = 'query'
    $http
    .post($location.path(), data)
    .success((res) ->
        if res.status == 'success'
           for k, v of res.data
                if _.str.endsWith(k, ':pv')
                    pv[k] = v
                else
                    uv[k] = v
            renderChart(pv, pv_chart, 'PV')
            # renderChart(uv, uv_chart, 'UV')
    )

Traceback:
Uncaught TypeError: Cannot read property 'mod' of null echarts-original.js:8961

test

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants