plotly/plotly.js · error · Error

Export format is not ${values}.

Error message

Export format is not ${values}.

What it means

Validation guard in Plotly.toImage: opts.format is checked with Lib.validate against the format attribute, which only allows the enumerated values 'png', 'jpeg', 'webp', 'svg' and the legacy 'full-json'. The throw fires when a caller requests any other format string (e.g. 'jpg', 'pdf', 'gif'), which the rasterizer cannot produce.

Source

Thrown at src/plot_api/to_image.js:111

    } else {
        gd = Lib.getGraphDiv(gd);
        data = Lib.extendDeep([], gd.data);
        layout = Lib.extendDeep({}, gd.layout);
        config = gd._context;
        fullLayout = gd._fullLayout || {};
    }

    function isImpliedOrValid(attr) {
        return !(attr in opts) || Lib.validate(opts[attr], attrs[attr]);
    }

    if((!isImpliedOrValid('width') && opts.width !== null) ||
        (!isImpliedOrValid('height') && opts.height !== null)) {
        throw new Error('Height and width should be pixel values.');
    }

    if(!isImpliedOrValid('format')) {
        throw new Error('Export format is not ' + Lib.join2(attrs.format.values, ', ', ' or ') + '.');
    }

    var fullOpts = {};

    function coerce(attr, dflt) {
        return Lib.coerce(opts, fullOpts, attrs, attr, dflt);
    }

    var format = coerce('format');
    var width = coerce('width');
    var height = coerce('height');
    var scale = coerce('scale');
    var setBackground = coerce('setBackground');
    var imageDataOnly = coerce('imageDataOnly');

    // put the cloned div somewhere off screen before attaching to DOM
    var clonedGd = document.createElement('div');
    clonedGd.style.position = 'absolute';

View on GitHub (pinned to 1d090e0b5f)

Solutions

  1. Use one of the supported formats: 'png', 'jpeg', 'webp', 'svg' (or 'full-json').
  2. Replace 'jpg' with 'jpeg'.
  3. For unsupported formats like PDF, convert the PNG/SVG output externally.
  4. Omit format to use the default ('png').
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at src/plot_api/to_image.js:111 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of plotly/plotly.js@1d090e0b5f (2026-09-02). Data as JSON: /api/errors/528e22cc618352a2. Report an issue: GitHub.