Coder Social home page Coder Social logo

Comments (4)

kener avatar kener commented on May 5, 2024

上代码?require图表了吗?如果出了各种控件就图表没出来,90%是这个问题,特别是单文件引入时也应该像这样,保持跟按需加载一样的格式,把要的图表也显式require,这样所需图表类型才被注册的库中,才能出图表
require([
'echarts',
'echarts/chart/pie'
],...)

from echarts.

EsonXie avatar EsonXie commented on May 5, 2024

var InitPieChart = function (Id, data) {
var affiliateChartOptions = function () {
var tempOptions = {
tooltip: {
trigger: 'item',
formatter: "{b} : {c} ({d}%)"
},
legend: {
orient: 'vertical',
x: 'left',
data: []
},
toolbox: {
show: true,
feature: {
restore: true
},
padding: [5, 50, 5, 5]
},
series: [
{
name: $("#" + Id).attr("data-title"),
type: "pie",
radius: [0, 100],
data: [
],
itemStyle: {
normal: {
label: {
show: false,
formatter: "{b}"
},
labelLine: {
show: false,
}
}
}
}
]
};

        var total = 0;
        $.each(data, function (name, value) {
            name = name.ReplaceAll("_", " ");
            tempOptions.legend.data.push(name);
            tempOptions.series[0].data.push({ name: name, value: value.Count });
            total += value.Count;
        });

        tempOptions.legend.data = tempOptions.legend.data.sort(function (item1, item2) {
            return item2.length - item1.length;
        });
        tempOptions.series[0].data = tempOptions.series[0].data.sort(function (item1, item2) {
            return item2.name.length - item1.name.length;
        });

        $("#" + Id + "Total").html(total);

        return tempOptions;
    }();

    var charts;
    require(['echarts/echarts', 'echarts/chart/pie'],
            function (ec, wd) {
                charts = ec;
                charts = charts.init($("#" + Id).get(0));
                charts.refresh();
                charts.setOption(affiliateChartOptions);
            }
        );
};

正常请求都没有问题,有时候加载不出,tools、legend也都没出来,我跟过http请求,有时候会停在请求完某些zrender的js之后。

from echarts.

kener avatar kener commented on May 5, 2024

了解,谢谢,我看看~

from echarts.

EsonXie avatar EsonXie commented on May 5, 2024

问题已经查出来了。。。 是我自己的代码有问题。。。
对不住大神了。。。。

from echarts.

Related Issues (20)

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.