Amcharts标题重叠

时间:2014-06-20 14:14:19

标签: javascript charts position title

我有一个这样的图表: function constructPieChart(chartData,chartDiv,showLegend,legendPos,color,         showValue,chartBottom){

showLegend = typeof showLegend !== 'undefined' ? showLegend : true;
legendPos = typeof legendPos !== 'undefined' ? legendPos : "right";

var pieChart = new AmCharts.AmPieChart();
pieChart.dataProvider = chartData;
pieChart.titleField = "title";
pieChart.valueField = "value";
pieChart.outlineColor = "#FFFFFF";
pieChart.minRadius = 150;

if (chartBottom != 0) {
    pieChart.marginTop = chartBottom;
}
pieChart.outlineAlpha = 0.8;
pieChart.outlineThickness = 2;
if (!showValue) {
    pieChart.labelText = "[[title]]";
    pieChart.labelRadius = 50;
    pieChart.pullOutRadius = 70;
}


// show different color
if (color != null) {

    for ( var i = 0; i < chartData.length; i++) {
        var objectTitle = chartData[i].title;
        if (objectTitle == "nötr") {
            colorList[i] = color[0];
        } else if (objectTitle == "pozitif") {
            colorList[i] = color[2];
        } else if (objectTitle == "soru") {
            colorList[i] = color[1];
        } else if (objectTitle == "check-in") {
            colorList[i] = color[4];
        } else if (objectTitle == "negatif") {
            colorList[i] = color[3];
        }
        // ////////////////
        else if (objectTitle == "Yeni Mesaj"
                || objectTitle == "Yeni Paylaşım") {
            colorList[i] = color[5];
        } else if (objectTitle == "Paylaşım" || objectTitle == "Retweet") {
            colorList[i] = color[6];
        }
        // /////////////////////
        else if (objectTitle == "twitter for android"
                || objectTitle == "Android") {
            colorList[i] = color[7];
        } else if (objectTitle == "twitter for iphone"
                || objectTitle == "Iphone") {
            colorList[i] = color[8];
        } else if (objectTitle == "twitter web client"
                || objectTitle == "Web Kullanicisi") {
            colorList[i] = color[9];
        } else if (objectTitle == "twitter for ipad"
                || objectTitle == "Ipad") {
            colorList[i] = color[10];
        } else if (objectTitle == "web" || objectTitle == "Web") {
            colorList[i] = color[11];
        } else if (objectTitle == "google" || objectTitle == "Google") {
            colorList[i] = color[12];
        } else if (objectTitle == "facebook" || objectTitle == "Facebook") {
            colorList[i] = color[13];
        } else if (objectTitle == "twitter for blackberry®"
                || objectTitle == "Blackberry") {
            colorList[i] = color[1];
        } else if (objectTitle == "twitter for windows phone"
                || objectTitle == "Windows Phone") {
            colorList[i] = color[2];
        } else if (objectTitle == "foursquare"
                || objectTitle == "Foursquare") {
            colorList[i] = color[3];
        }
        // //////////
        else if (objectTitle == "tr" || objectTitle == "Türkçe") {
            colorList[i] = color[3];
        } else if (objectTitle == "de" || objectTitle == "Almanca") {
            colorList[i] = color[7];
        } else if (objectTitle == "es" || objectTitle == "İspanyolca") {
            colorList[i] = color[6];
        } else if (objectTitle == "en" || objectTitle == "İngilizce") {
            colorList[i] = color[13];
        } else if (objectTitle == "fr" || objectTitle == "Fransızca") {
            colorList[i] = color[1];
        } else if (objectTitle == "it" || objectTitle == "İtalyanca") {
            colorList[i] = color[2];
        } else if (objectTitle == "la" || objectTitle == "Latin") {
            colorList[i] = color[11];
        } else if (objectTitle == "ku" || objectTitle == "Kürtçe") {
            colorList[i] = color[4];
        }
        // ////////////////
        else if (objectTitle == "haber") {
            colorList[i] = color[1];
        } else if (objectTitle == "forum") {
            colorList[i] = color[0];
        } else if (objectTitle == "gazete") {
            colorList[i] = color[3];
        } else if (objectTitle == "blog") {
            colorList[i] = color[4];
        } else if (objectTitle == "dergi") {
            colorList[i] = color[9];
        } else if (objectTitle == "Genel") {
            colorList[i] = color[5];
        } else if (objectTitle == "Diger") {
            colorList[i] = color[14];
        }

    }

    pieChart.colors = colorList;
}
// //

if (showLegend) {
    var pieLegend = new AmCharts.AmLegend();
    pieLegend.align = "center";
    pieLegend.position = legendPos;
    pieLegend.markerType = "square";
    pieLegend.autoMargins = false;
    pieLegend.textClickEnabled = false; // required for clickLabel event to
    // trigger
    pieLegend.switchable = false; // required for clickMarker event to

    pieChart.addLegend(pieLegend);
}

var clickSliceListener = function(objData) {
    if (typeof panelBlock !== "undefined") {
        panelBlock.show();
    }
    if (typeof applyFilter !== "undefined") {
        chart.labelRadius=50;
        applyFilter([ {
            name : 'value',
            value : objData.dataItem.title
        }, {
            name : 'isAdded',
            value : objData.dataItem.pulled
        } ]);
    }
    // $("tspan:contains('chart by amcharts.com')").remove();
    return false;
};
pieChart.addListener("clickSlice", clickSliceListener);

// this makes the chart 3D
pieChart.depth3D = 15;
pieChart.angle = 30;
// pieChart.pullOutRadius = 0;

pieChart.write(chartDiv);

return pieChart;

}

同样如下: http://www.amcharts.com/demos/simple-pie-chart/

但是当你点击其中一个标题时,它会上升并重叠上面的标题。我怎么能避免这种重叠?

提前完成。

1 个答案:

答案 0 :(得分:-1)

http://docs.amcharts.com/3/javascriptcharts/AmCharts 您可以使用正确的数字

设置marginTop属性