簡體   English   中英

如何擺脫餅圖周圍多余的空白? 使用 amcharts 4 庫

[英]How do I get rid of the excess white space around pie chart? Using amcharts 4 libs

我一直在嘗試傳播餅圖,我必須覆蓋頁面上的大部分“卡片”,但無論我削減多少邊距,它要么開始消失在卡片內的另一個邊框后面。 我注意到 amcharts lib 創建了一堆開發人員無法控制的層。 無論如何,這就是我要說的: 在此處輸入圖像描述

這是生成的 HTML 代碼片段: 在此處輸入圖像描述

這是我的 javascript:

 am4core.ready(function () {

            //Themes                
            var chartType = am4charts.PieChart3D;
            var seriesType = new am4charts.PieSeries3D();
        
            //Create Chart and Series 
            var chart = createChart(thisWidget.id, chartType);

            var pieSeries = chart.series.push(seriesType); // 3D Pie Chart

            //Set properties
            chart.hiddenState.properties.opacity = 0; // 3D Pie Chart: this creates initial fade-in
            
            pieSeries.slices.template.cornerRadius = 6;  //Pie Chart with varying Radius + 3D
            pieSeries.colors.step = 3;  //Pie Chart with varying Radius + 3D
            pieSeries.angle = 45;

            //color
            if (colorTheme) {
                pieSeries.colors.list = getAmchartCustomTheme(colorTheme);
            }
                
            //data types 
            pieSeries.dataFields.value = "count";
            pieSeries.dataFields.category = "tag";
            chart.paddingTop = 0;
            chart.marginTop = 0;
            
            // Put a thick white border around each Slice
            pieSeries.slices.template.stroke = am4core.color("#fff");
            pieSeries.slices.template
                // change the cursor on hover to make it apparent the object can be interacted with
                .cursorOverStyle = [
                    {
                        "property": "cursor",
                        "value": "pointer"
                    }
                ];

            //Make the slice move on hover
            var slice = pieSeries.slices.template;
            slice.states.getKey("active").properties.shiftRadius = 0;
            slice.states.getKey("hover").properties.scale = 1;
            slice.states.getKey("hover").properties.shiftRadius = 0.2;

            //increase size of Chart
            chart.svgContainer.htmlElement.style.height = targetHeight;
            chart.svgContainer.autoresize = true;

            //disable Ticks and labels to save space
            pieSeries.labels.template.disabled = true;

            //registering events
            pieSeries.slices.template.events.on("hit", function (ev) {
                var category = ev.target.slice._dataItem.properties.category;
                addInput(category);
            });
            pieSeries.alignLabels = false;       

            // Create a base filter effect (as if it's not there) for the hover to return to
            var shadow = pieSeries.slices.template.filters.push(new am4core.DropShadowFilter);
            shadow.opacity = 0;

            // Create hover state
            var hoverState = pieSeries.slices.template.states.getKey("hover"); // normally we have to create the hover state, in this case it already exists

            // Slightly shift the shadow and make it more prominent on hover
            var hoverShadow = hoverState.filters.push(new am4core.DropShadowFilter);
            hoverShadow.opacity = 0.7;
            hoverShadow.blur = 5;

            //Add Data
            chart.data = displayItems;
           
        })
        
    

strokeOpacity = 0 or strokeWidth = 0應該可以解決問題。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM