exportFileName: String

While exporting any chart, “Chart” is used as the default file name with corresponding extension “jpg” or “png”. You can override this name using exportFileName property.

Default: Chart
var  chart =  new  CanvasJS("container",
{
 .
 .
 exportFileName: "Range Area",
 .
 .
});
chart.render();

Try Editing The Code

If you have any questions, please feel free to ask in our forums.Ask Question

21 Comments

  1. Pingback: CanvasJS Charts 1.5 goes GA - CanvasJS

  2. How does one change the exportFileName dynamically? I’ve tried chart.options.exportFileName = “new name”; and that has no effect even though alert(chart.options.exportFileName) shows me the original name.

    • Sunil Urs says:

      After updating any property (suggested to do in batches) you need to call chart.render() method. This internally updates the properties that have changed.

  3. Ok, what is the solution… I tried:
    function doChange() {
    chart.options.title.text = “test”;
    chart.options.exportFileName = “test”;
    chart.render();
    }
    Changing the “title” works. What am I missing on the “exportFileName”?

    • Sunil Urs says:

      Jorge,

      You cannot do this via the CanvasJS API itself. But given that you have the JSON data, you should be able to construct these files in JavaScript and export the same using filesaver.

  4. The following simply doesn’t work when attempting to change the export file name…

    var chart;
    window.onload = function () {
    chart = new CanvasJS.Chart(“chartContainer”,
    {
    title: {
    text: “Overriding Default Export File Name”
    },
    exportFileName: “Range Spline Area”, //Give any name accordingly
    exportEnabled: true,
    axisY: {
    includeZero: false,
    },
    axisX: {
    interval: 10
    },
    data: [
    {
    type: “rangeSplineArea”,
    dataPoints: [
    { x: 10, y: [18.86, 40.76] },
    { x: 20, y: [55.95, 78.26] },
    { x: 30, y: [48.27, 72.90] },
    { x: 40, y: [67.65, 99.65] },
    { x: 50, y: [25.50, 51.26] }
    ]
    }
    ]
    });
    chart.render();
    }
    function doclick() {
    chart.options.title.text = “New Title”;
    chart.options.exportFileName = “NewFileName”;
    chart.render();
    }

    Change Stuff

  5. Christian says:

    Hi,

    is it possible to use canvas.toDataURL direct in the script, while the export button is disabled?

  6. Ambrosius says:

    Hi,
    Is it possible to switch the backgroundcolor to normal in case of saving the picture?
    My page design is darkgrey, but for the export it looks a bit weird.

    Thanks!
    Ambrosius

If you have any questions, please feel free to ask in our forums. Ask Question