Echarts 統計圖,顏色、懸浮提示、字體大小顏色、餅圖中間字體 基本配置

  var myChart = echarts.init(document.getElementById('StudentTemperature'));
    option = {
        //提示框
        tooltip: {
            trigger: 'item',
            formatter: '{a} <br/>{b}: {c} ({d}%)'
        },
        legend: {
            orient: 'vertical',
            left: 10,
            textStyle: {
                fontSize: 12, //字體大小
                color: '#ffffff' //字體顏色
            },
        },
        //柱子顏色設置
        color: ['#03fffc', '#f22f3d', '#78ce5e', '#fffd5e'],
        series: [{
            name: '訪問來源',
            type: 'pie',
            radius: ['50%', '70%'],
            avoidLabelOverlap: false,
            label: {
                normal: {
                    show: true,
                }
            }
        }]
    };
    myChart.setOption(option);

    $.ajax({
        url: APIURL,
        type: 'get',
        dataType: 'jsonp',
        data: {
            responderid: 'xx',
            action: 'xx',
            dataType: 'xx'
        },
        success: function(msg) {
            // 
            $('.one').html(msg.second.BaseInfo[0].title)
            var data = [{
                name: '',
                value: msg.second.Data[0].noCheck
            }, {
                name: 'x',
                value: msg.second.Data[0].ng
            }, {
                name: 'x',
                value: msg.second.Data[0].ok
            }, {
                name: 'x',
                value: msg.second.Data[0].noIn
            }]
            myChart.setOption({
                series: [{
                    data: data
                }],
                graphic: { //圖形中間文字
                    type: "text",
                    left: "center",
                    top: "center",
                    style: {
                        text: msg.second.BaseInfo[0].title,
                        textAlign: "center",
                        fill: "#fff",
                        fontSize: 15,
                    }
                }
            })
        },
        error: function(err) {
            console.log(err);
        }
    });

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章