简体   繁体   中英

Left align pie chart (amCharts)

I am using amcharts to render a simple pie chart and I would like the pie chart to start on the left most edge of the container. I have gone through the amcharts API but nothing seems to do what I need. Below you can see the code I am using and an image of what I get (With some red lines drawn on of what I want图表呈现方式的示例

        am4core.useTheme(am4themes_animated);
        // Themes end

        var data = [
          {
            revenueSource: "Fee Revenue",
            value: 356
          },
          {
            revenueSource: "Retail Revenue",
            value: 247
          },
          {
            revenueSource: "Ticket Revenue",
            value: 9876
          }
        ];

        var chart1 = am4core.create("chartdiv", am4charts.PieChart);
        chart1.hiddenState.properties.opacity = 0;
        chart1.data = data;
        chart1.innerRadius = am4core.percent(50);
        chart1.legend = new am4charts.Legend();
        chart1.legend.position = "right";

        var series1 = chart1.series.push(new am4charts.PieSeries());
        series1.dataFields.value = "value";
        series1.dataFields.category = "revenueSource";
        series1.ticks.template.disabled = true;
        series1.labels.template.disabled = true;

Note. The div that the chart renders within has a height of 400px and a width of 100%

chart1.seriesContainer.align = "left"; Should do the job.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM