Add Chart to Document
Definition
This action allows you to embed a Google Sheets Chart directly into a specified location within a Google Document. It automates the process of creating data-rich documents by merging visual data from spreadsheets into your reports, proposals, or other text-based files.
Key capabilities:
- Locate: Finds a specific chart object within a Google Sheet using its internal title.
- Insert: Places the chart into a precise location in a Google Doc by replacing a text placeholder.
- Format: Customizes the chart’s dimensions and click behavior (URL link).
Important: This action works with Chart Objects (Graphs, Pie Charts, Bar Charts) that you have inserted into your spreadsheet via the Insert > Chart menu. It does not take a screenshot of a range of cells or a table of raw numbers.
⚠️ Prerequisite: Setting the Chart Title
For Zenphi to find the correct chart, you must explicitly set the Chart Title inside the chart’s settings.
Common Mistake: Typing a title in a cell above the chart does not count. Zenphi cannot see that text. It looks for the internal metadata of the chart object itself.
How to set the title correctly:
- Open your Google Sheet.
- Double-click the chart itself to open the Chart Editor panel on the right.
- Click the Customize tab.
- Expand the Chart & axis titles section.
- Under “Title text”, enter a unique name (e.g.,
Revenue_Q1). This is the value you will use in Zenphi.
Tip: If you do not want a visible title on your chart, you can set the “Title text color” to White (or match your background color). This keeps the title invisible to the human eye but readable to Zenphi.
Inputs
- Connection
- Purpose: Authorizes Zenphi to access your Google Docs and Sheets.
- Practical Guidance: Select your Google Workspace connection. This account must have at least “Viewer” access to the Sheet and “Editor” access to the Document.
- Spreadsheet File Id
- Purpose: Identifies the specific Google Sheets file containing the source chart.
- Practical Guidance: Use the Token Picker to select the ID from a previous “Find File” or “Trigger” step to ensure the flow works even if the file is moved.
- Sheet Name
- Purpose: Specifies the exact tab (worksheet) where the chart lives.
- Practical Guidance: Select from the dropdown list if using a static file, or type the exact name (case-sensitive) if using dynamic values.
- Chart Title
- Purpose: The unique identifier for the chart.
- Practical Guidance: This must match the text you entered in the Chart Editor > Customize settings exactly.
- Target Doc
- Purpose: The ID of the Google Document where the chart will be inserted.
- Practical Guidance: Usually, this is the Output ID from a preceding “Create Document from Template” action.
- Chart Placeholder Name
- Purpose: Tells Zenphi exactly where to place the image.
- Behavior: Zenphi searches for this text string in your document and completely replaces it with the chart image. The text itself will no longer exist in the final document.
- Practical Guidance: Enter the exact string you typed in your document template, including any brackets.
- Example: If your doc says
{revenue_chart}, you must enter{revenue_chart}in this field.
- Chart Width
- Purpose: Sets the width of the image in pixels.
- Recommendation:
600is a safe standard for A4/Letter pages with normal margins.
- Chart Height
- Purpose: Sets the height of the image in pixels.
- Recommendation: Leave this Empty. Zenphi will automatically calculate the height based on the width to preserve the chart’s aspect ratio (preventing stretching or squashing).
- Chart URL Mode
- Purpose: Determines what happens if a user clicks the chart in the final document.
- Options:
None: Standard image.Sheet URL: Opens the source Google Sheet (useful for audit trails).Custom URL: Opens a specific link you provide.
Outputs
- Document Id
- The ID of the updated document. This is useful for passing to subsequent steps like “Convert to PDF” or “Send Email.”
Example Scenario: The Monthly Sales Report
Goal: A sales manager needs to generate a PDF report for the North American team, including a specific “Regional Performance” chart.
Workflow Steps:
- Trigger: Scheduled Flow (Monthly).
- Action: Create Document from Template. (Generates the text report and outputs a
New Document ID).- Template contains placeholder:
{regional_chart}
- Template contains placeholder:
- Action: Add Chart to Doc.
- Spreadsheet: Master Sales Data.
- Chart Title: “North_America_Perf” (This title matches the chart in the Google Sheet).
- Target Doc:
New Document ID(from Step 2). - Placeholder:
{regional_chart}. - Width:
600.
- Action: Convert Document to PDF.
- Action: Send Email (Attaching the PDF).
Outcome: The final PDF contains the specific chart for North America, perfectly resized. The text {regional_chart} has disappeared, replaced entirely by the visual graph.
Troubleshooting
Problem: The flow runs successfully, but the chart is missing from the document.
- Check 1: Does the Chart Title in the action match the chart in Google Sheets exactly? (Check for spaces or typos).
- Check 2: Did you type the title in a cell above the chart instead of in the Chart Settings? (Review the Prerequisite section above).
Problem: The placeholder text (e.g., {chart}) is still visible in the document.
- Check: Ensure the Chart Placeholder Name in the action inputs includes the brackets. If your doc has
{chart}, do not just typechartin the input field.
Problem: The chart looks stretched or squashed.
- Check: Did you set a specific value for Chart Height? Clear that field and let Zenphi calculate it automatically based on the Width.