如果值为0,则隐藏图例 - Kendo UI饼图

时间:2016-02-05 01:24:57

标签: javascript jquery charts kendo-ui pie-chart

我有剑道饼图,即使没有任何价值,它的传奇仍然显示出来。 是否可以隐藏没有值或值= 0的图例。我通过函数传递值,所以我不知道哪个值是0.我已尝试在数组中设置数据但我是卡住。任何人都可以帮助我...

这是我的剧本:

function createPieChart(a,b,c,d) {
    var e = a+b+c+d;
    var aa = a/e*100;
    var bb = b/e*100;
    var cc = c/e*100;
    var dd = d/e*100;

    var perA = Math.round(aa*100.0)/100.0;
    var perB = Math.round(bb*100.0)/100.0;
    var perC = Math.round(cc*100.0)/100.0;
    var perD = Math.round(dd*100.0)/100.0;

    var arrValue = [perA, perB, perC, perD];

    var data = [{
        "source": "Positive",
        "percentage": perA,
        "color": "#9de219",
        "explode": true
    },{
        "source": "Neutral",
        "percentage": perB,
        "color": "#90cc38"
    },{
        "source": "Negative",
        "percentage": perC,
        "color": "#068c35"
    },{
        "source": "Unknown",
        "percentage": perD,
        "color": "#006634"
    }];

    $("#chart_div").kendoChart({
        dataSource: {
          transport: {
            read: function(e) {
              e.success(data);
            }
          }
        },
        title: {
            position: "top",
            text: "Sentiment Result"
        },
        legend: {
            position: "bottom",
            visible: true
        },
        seriesDefaults: {
            labels: {
                visible: false,
                template: "#= category #: \n #= value#%"
            }
        },
        series: [{
            type: "pie",
            startAngle: 150,
            field: "percentage",
            categoryField: "source",
            colorField: "color",
            explodeField: "explode"
        }],
        tooltip: {
            visible: true,
            template: "${ category } - ${ value }%"
        }
}

1 个答案:

答案 0 :(得分:0)

替换此代码:

.686P
.MODEL FLAT
.STACK 4096

EXTERN  _printf     :PROC
EXTERN  _scanf      :PROC

.DATA
szRead          BYTE    "%s", 0
szStr           BYTE    80 DUP (?)

.CODE

_main   PROC

    lea     edx, szStr
    push    edx
    lea     ebx, szRead
    push    ebx
    call    _scanf
    add     esp, 8

    push    edx
    lea     ebx, szRead
    push    ebx
    call    _printf
    add     esp, 8

    xor     eax, eax
    ret

_main   ENDP

END

使用此代码:

var data = [{
        "source": "Positive",
        "percentage": perA,
        "color": "#9de219",
        "explode": true
    },{
        "source": "Neutral",
        "percentage": perB,
        "color": "#90cc38"
    },{
        "source": "Negative",
        "percentage": perC,
        "color": "#068c35"
    },{
        "source": "Unknown",
        "percentage": perD,
        "color": "#006634"
    }];