Journalism Dataviz - v1.0.30
    Preparing search index...

    Function updateInfoDW

    • Updates the title, description, and notes of a Datawrapper chart, table, or map in one API request.

      Only supplied fields are updated. Omit a field or pass undefined to preserve its existing value; pass an empty string to clear it. At least one field must be supplied. Other chart settings are preserved by Datawrapper's partial metadata update.

      The API key is read from DATAWRAPPER_KEY by default. This function updates the draft visualization; call publishChartDW() afterward to publish the changes.

      Parameters

      • chartId: string

        The ID of the Datawrapper chart, table, or map to update.

      • metadata: { description?: string; note?: string; title?: string }

        The fields to update. At least one must be supplied.

        • Optionaldescription?: string

          The description below the title, stored as metadata.describe.intro. An empty string clears it.

        • Optionalnote?: string

          The notes in the visualization's footer, stored as metadata.annotate.notes. An empty string clears them.

        • Optionaltitle?: string

          The visualization's headline. An empty string clears it.

      • options: { apiKey?: string; returnResponse?: boolean } = {}

        Optional authentication and response settings.

        • OptionalapiKey?: string

          The name of the environment variable containing the API key. Defaults to "DATAWRAPPER_KEY".

        • OptionalreturnResponse?: boolean

          If true, returns the unconsumed response without checking its status. Defaults to false.

      Returns Promise<void | Response>

      A promise resolving to void, or to the raw Response when requested. By default, non-200 responses throw an error.

      import { updateInfoDW } from "@nshiab/journalism-dataviz";

      await updateInfoDW("abcde", {
      title: "Sales keep rising",
      description: "Monthly revenue since January 2025.",
      note: "Source: company filings.",
      });
      // Clear the notes while preserving the title and description.
      await updateInfoDW("abcde", { note: "" }, { apiKey: "DW_KEY" });
      // Inspect the raw response, including non-200 responses.
      const response = await updateInfoDW("abcde", { title: "New title" }, {
      returnResponse: true,
      });
      console.log(response?.status);