左对齐饼图(amCharts)

时间:2019-12-10 22:11:07

标签: javascript amcharts

我正在使用amcharts绘制一个简单的饼图,我希望饼图从容器的最左侧开始。 我已经通过了amcharts API,但似乎什么也没做。 在下面,您可以看到我正在使用的代码以及获得的图像(在我想要的东西上画了一些红线) Example of how the chart renders

        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;

注意。图表呈现的div的高度为400px,宽度为100%

1 个答案:

答案 0 :(得分:1)

chart1.seriesContainer.align = "left"; 应该做的。