🔬 Generate dynamic line chart from JSON data to upload to Google Drive

2,611 views · 🔬 Document Extraction & Analysis

Description

What Does This Flow Do?

This workflow demonstrates how to dynamically generate a line chart using the QuickChart node based on data provided in a JSON object and then upload the resulting chart image to Google Drive.

chart.jpg

Use Cases

How it Works

  1. Trigger: The workflow starts manually when you click ‘Test workflow’.
  2. Set Sample Data: A Set node (Edit Fields: Set JSON data to test) defines a sample JSON object named jsonData. This object contains:
    • reportTitle: A title (not used in the chart generation in this example, but useful for context).
    • labels: An array of strings representing the labels for the chart’s X-axis (e.g., [“Q1”, “Q2”, “Q3”, “Q4”]).
    • salesData: An array of numbers representing the data points for the chart’s Y-axis (e.g., [1250, 1800, 1550, 2100]).
  3. Generate Chart: The QuickChart node is configured to:
    • Create a line chart.
    • Dynamically read labels from the jsonData.labels array (Labels Mode: From Array).
    • Use the jsonData.salesData array as the input data (Note: This configuration places data in the top-level ‘Data’ field. For more complex charts with multiple datasets or specific dataset options, configure datasets under ‘Dataset Options’ instead).
    • The node outputs the generated chart image as binary data in a field named data.
  4. Upload to Google Drive: The Google Drive node (Google Drive: Upload File):
    • Takes the binary data (data) from the QuickChart node.
    • Uploads the image to your specified Google Drive folder.
    • Dynamically names the file based on its extension (e.g., chart.png).

Setup Steps

  1. Import: Import this template into your n8n instance.
  2. Configure Google Drive Credentials:
    • Select the Google Drive: Upload File node.
    • You MUST configure your own Google Drive credentials. Click on the ‘Credentials’ dropdown and either select existing credentials or create new ones by following the authentication prompts.
  3. (Optional) Customize Google Drive Folder: In the Google Drive: Upload File node, you can change the Drive ID and Folder ID to specify exactly where the chart should be uploaded.
  4. Activate: Activate the workflow if you want it to run automatically based on a different trigger.

How to Use & Customize

Nodes Used


Tags: (Suggestions for tags field)

QuickChart, Chart, Visualization, Line Chart, Google Drive, Reporting, Automation


🔗 Nodes Used

Google Drive, QuickChart

📥 Import

Download workflow.json and import into n8n: Workflow menu → Import from File

📖 Importing guide · 🔑 Credential setup