Darshu
Darshu

Reputation: 1

export google chart as PDF in angularjs

I am trying to export the chart as image but no luck.

I tried searching online but could not find the way am using the google chart

my controller

       $scope.chartObject = {
            "type": "PieChart",
            "displayed": true,
            "data": {
                "cols": [
                {
                    "id": "month",
                    "label": "Month",
                    "type": "string",
                    "p": {}
                },
                {
                    "id": "laptop-id",
                    "label": "Laptop",
                    "type": "number",
                    "p": {}
                },
                {
                    "id": "desktop-id",
                    "label": "Desktop",
                    "type": "number",
                    "p": {}
                },
                {
                    "id": "server-id",
                    "label": "Server",
                    "type": "number",
                    "p": {}
                },
                {
                    "id": "cost-id",
                    "label": "Shipping",
                    "type": "number"
                }
                ],
                "rows": [
                {
                    "c": [
                    {
                        "v": "January"
                    },
                    {
                        "v": 19,
                        "f": "42 items"
                    },
                    {
                        "v": 12,
                        "f": "Ony 12 items"
                    },
                    {
                        "v": 7,
                        "f": "7 servers"
                    },
                    {
                        "v": 4
                    }
                    ]
                },
                {
                    "c": [
                    {
                        "v": "February"
                    },
                    {
                        "v": 13
                    },
                    {
                        "v": 1,
                        "f": "1 unit (Out of stock this month)"
                    },
                    {
                        "v": 12
                    },
                    {
                        "v": 2
                    }
                    ]
                },
                {
                    "c": [
                    {
                        "v": "March"
                    },
                    {
                        "v": 24
                    },
                    {
                        "v": 5
                    },
                    {
                        "v": 11
                    },
                    {
                        "v": 6
                    }
                    ]
                }
                ]
            },
            "options": {
                "title": "Sales per month",
                "isStacked": "true",
                "fill": 20,
                "displayExactValues": true,
                "vAxis": {
                    "title": "Sales unit",
                    "gridlines": {
                        "count": 10
                    }
                },
                "hAxis": {
                    "title": "Date"
                }
            },
            "formatters": {}
        };

HTML code

    <div google-chart chart="chartObject" style="{{cssStyle}}"></div>

Is there any option other than google.visualization?

Upvotes: 0

Views: 1388

Answers (1)

dieuvn3b
dieuvn3b

Reputation: 6114

I think you can export google chart as images by canvas. Now, i am using html2canvas to capture my chart and export it as PNG file

Upvotes: 1

Related Questions