plotly/plotly_display

Source   Edit  

Procs

proc parseTraces[T](traces: seq[Trace[T]]): string
parses the traces of a Plot object to strings suitable for plotly by creating a JsonNode and converting to string repr Source   Edit  
proc save(p: SomePlot; htmlPath = ""; htmlTemplate = defaultTmplString;
          filename = ""; autoResize = true): string
Source   Edit  
proc saveImage(p: SomePlot; filename: string; htmlPath = "";
               htmlTemplate = defaultTmplString; removeTempFile = false;
               autoResize = false)
Saves the image under the given filename supported filetypes:
  • jpg, png, svg, webp

Note: only supported if compiled with --threads:on!

If the webview target is used, the plot is only saved and not shown (for long; webview closed after image saved correctly).

If htmlPath is given the file is stored in the given path and name. Else a suitable name will be generated based on the current time.

htmlTemplate allows to overwrite the default HTML template.

If removeTempFile is true, the temporary file will be deleted after a short while (not recommended).

If autoResize is true, the shown plot will automatically resize according to the browser window size. This overrides any possible custom sizes for the plot. By default it is disabled for plots that should be saved.

Source   Edit  
proc show(grid: Grid; filename = ""; htmlPath = "";
          htmlTemplate = defaultTmplString; removeTempFile = false;
          autoResize = true) {....raises: [ResourceExhaustedError, OSError,
                                        IOError, ValueError, KeyError], tags: [
    TimeEffect, WriteDirEffect, ReadDirEffect, ReadEnvEffect, ReadIOEffect,
    RootEffect, WriteIOEffect, ExecIOEffect], forbids: [].}

Displays the Grid plot. Converts the grid to a call to combine and calls show on it.

If htmlPath is given the file is stored in the given path and name. Else a suitable name will be generated based on the current time.

htmlTemplate allows to overwrite the default HTML template.

If removeTempFile is true, the temporary file will be deleted after a short while (not recommended).

If autoResize is true, the shown plot will automatically resize according to the browser window size. This overrides any possible custom sizes for the plot. By default it is disabled for plots that should be saved.

Source   Edit  
proc show(p: SomePlot; filename = ""; htmlPath = "";
          htmlTemplate = defaultTmplString; onlySave: static bool = false;
          removeTempFile = false; autoResize = true)

Creates the temporary Html file using save, and opens the user's default browser.

If onlySave is true, the plot is only saved and "not shown". However this only works on the webview target. And a webview window has to be opened, but will be closed automatically the moment the plot is saved.

If htmlPath is given the file is stored in the given path and name. Else a suitable name will be generated based on the current time.

htmlTemplate allows to overwrite the default HTML template.

If removeTempFile is true, the temporary file will be deleted after a short while (not recommended).

If autoResize is true, the shown plot will automatically resize according to the browser window size. This overrides any possible custom sizes for the plot. By default it is disabled for plots that should be saved.

Source   Edit