1

I have created a chart with amcharts5 but I am unable to export the chart via amcharts build-in "Exporting Menu". I get the following error in my console upon pressing "PDF" in the exporting menu:

Error in console

Looking at the "Exporting.ts" file gives the following: enter image description here

I have scoured the internet looking for answers, but I have come up empty handed. Any help would be appriciated.

  • Vue: v3.2.36
  • Amcharts: v5.3.4
  • Code:

<template>
    <div class="hello" ref="pie_chart_share_revenue" />
</template>

<script>
import * as am5 from '@amcharts/amcharts5';
import * as am5percent from '@amcharts/amcharts5/percent';
import am5themes_Animated from '@amcharts/amcharts5/themes/Animated';
import * as am5plugins_exporting from "@amcharts/amcharts5/plugins/exporting";

export default {
    props: {
        categories: Array,
    },
    data() {
        return {
            mainChart: null
        }
    },
    mounted() {
        let root = am5.Root.new(this.$refs.pie_chart_share_revenue);
        root.numberFormatter.set("numberFormat", "#,###.00");
        root.setThemes([am5themes_Animated.new(root)]);

        let chart = root.container.children.push(
            am5percent.PieChart.new(root, {
                layout: root.verticalHorizontal
            })
        );

        // Define data
        let data = this.categories;

        // Create series
        let series = chart.series.push(
            am5percent.PieSeries.new(root, {
                name: "Share revenue",
                valueField: "value",
                categoryField: "label",
                tooltip: am5.Tooltip.new(root, {
                    labelText: "[bold]{category}[/]\n{value.formatNumber()}"
                })
            })
        );

        series.data.setAll(data);

        let title = chart.children.unshift(am5.Label.new(root, {
            text: "Categories share of revenue",
            fontSize: 24,
            textAlign: "center",
            width: am5.p100,
            visible: false
        }));

        let exporting = am5plugins_exporting.Exporting.new(root, {
            menu: am5plugins_exporting.ExportingMenu.new(root, {}),
            filePrefix: "Categories share of revenue",
            title: "Categories share of revenue"
        });

        exporting.events.on("exportstarted", function() {
            title.show(0);
        });

        exporting.events.on("exportfinished", function() {
            title.hide(0);
        });

        series.appear();
        chart.appear();

        this.mainChart = root;
    },
    beforeDestroy() {
        if (this.mainChart) {
            this.mainChart.dispose();
        }
    },
}
</script>

<style scoped>
.hello {
    width: 100%;
    height:500px;
}
</style>
Anders
  • 105
  • 1
  • 9
  • Hy, please [don't upload text, table or error message as image](https://meta.stackoverflow.com/questions/285551/why-should-i-not-upload-images-of-code-data-errors/285557#285557). Edit your question to contain all the information in text form - consider to use the editor's formatting options. Also see [How to Ask](https://stackoverflow.com/help/how-to-ask) – Daxelarne Feb 22 '23 at 10:02

0 Answers0