Infographic creation

From nicepkg/ai-workflow · View interactive version

Infographic creation is an AI agent skill from the GitHub repository nicepkg/ai-workflow. Create beautiful infographics based on the given text content. Use this when users request creating infographics.

How to use this skill

Skill file

An infographic (Infographic) transforms data, information, and knowledge into perceivable visual language. It combines visual design with data visualization, using intuitive symbols to compress complex information and help audiences quickly understand and remember key points.

Infographic = Information Structure + Visual Expression

This is a task that utilizes AntV Infographic to create visual infographics.

Before you start the task, you need to understand the AntV Infographic Syntax specification, including template lists, data structures, themes, and more.

SPECs

AntV Infographic Syntax

AntV Infographic Syntax is a mermaid-like DSL for describing infographic rendering configuration. It uses indentation to describe information, has strong robustness, and makes it easy to render infographics through AI streaming output. It mainly contains the following information:

  1. template: Use template to express text information structure.
  2. data: the infographic data, which contains title, desc, items, etc. The items is an array containing label, value, desc, icon, children, etc.
  3. theme: Theme contains palette, font, and other styling options.

e.g.:

infographic list-row-horizontal-icon-arrow
data
  title Title
  desc Description
  items
    - label Label
      value 12.5
      desc Explanation
      icon mdi/rocket-launch
theme
  palette #3b82f6 #8b5cf6 #f97316

The Syntax

e.g. dark theme with custom palette:

```plain

infographic list-row-simple-horizontal-arrow

theme dark

palette

data

items

desc Start

desc In Progress

desc Complete

```

Common stylization types include:

e.g: Hand-drawn style (rough):

```plain

infographic list-row-simple-horizontal-arrow

theme

stylize rough

base

text

font-family 851tegakizatsu

data

items

desc Start

desc In Progress

desc Complete

```

Typescript definition for data field:

interface Data {
  title?: string;
  desc?: string;
  items: ItemDatum[];
  [key: string]: any;
}

interface ItemDatum {
  icon?: string;
  label?: string;
  desc?: string;
  value?: number;
  illus?: string;
  children?: ItemDatum[];
  [key: string]: any;
}

Icon and Illustration Resources

Icons (from Iconify):

Illustrations (from unDraw):

Usage Tips:

Available Templates

Template Selection Guidelines:

Example

Draw an information graph of the Internet technology evolution

infographic list-row-horizontal-icon-arrow
data
  title Internet Technology Evolution
  desc From Web 1.0 to AI era, key milestones
  items
    - time 1991
      label Web 1.0
      desc Tim Berners-Lee published the first website, opening the Internet era
      icon mdi/web
    - time 2004
      label Web 2.0
      desc Social media and user-generated content become mainstream
      icon mdi/account-multiple
    - time 2007
      label Mobile
      desc iPhone released, smartphone changes the world
      icon mdi/cellphone
    - time 2015
      label Cloud Native
      desc Containerization and microservices architecture are widely used
      icon mdi/cloud
    - time 2020
      label Low Code
      desc Visual development lowers the technology threshold
      icon mdi/application-brackets
    - time 2023
      label AI Large Model
      desc ChatGPT ignites the generative AI revolution
      icon mdi/brain

Example 2: Using Illustrations

infographic sequence-horizontal-zigzag-simple-illus
data
  title Product Development Phases
  desc Key stages in our development process
  items
    - label Research
      desc Understanding user needs
      illus user-research
    - label Design
      desc Creating user experience
      illus design-thinking
    - label Development
      desc Building the product
      illus coding
    - label Launch
      desc Going to market
      illus launch-day

Creation Process

Step 1: Understanding User Requirements

Before creating the infographic, it is important to understand the user's requirements and the information they want to present. This will help in defining the template and the data structure.

If the user provides a clear and concise description of the information they want to present, break down the information into a clear and concise structure.

Otherwise, ask the user for clarification (e.g., "Please provide a clear and concise description of the information you want to present.", "Which template would you prefer to use?")

CRITICAL NOTE: Must respect the language of the user's input content. e.g. if the user's input content is in Chinese, the text content in infographic syntax must be in Chinese.

Step 2: Rendering the Infographic

Once you have the final AntV Infographic Syntax, you can generate the complete infographic HTML file by following these steps:

  1. Create a complete HTML file with the following structure:

The Html template you can follow:

<div id="container"></div>
<script src="https://unpkg.com/@antv/infographic@latest/dist/infographic.min.js"></script>
<script>
// Resource Loader Script
// Use the following resource loader script to handle icon and illustration loading:
const svgTextCache = new Map();
const pendingRequests = new Map();

AntVInfographic.registerResourceLoader(async (config) => {
    const { data, scene } = config;

    try {
        const key = `${scene}::${data}`;
        let svgText;

        // 1. Check cache
        if (svgTextCache.has(key)) {
            svgText = svgTextCache.get(key);
        }
        // 2. Check if request is already in progress
        else if (pendingRequests.has(key)) {
            svgText = await pendingRequests.get(key);
        }
        // 3. Make new request
        else {
            const fetchPromise = (async () => {
                try {
                    let url;

                    if (scene === 'icon') {
                        url = `https://api.iconify.design/${data}.svg`;
                    } else if (scene === 'illus') {
                        url = `https://raw.githubusercontent.com/balazser/undraw-svg-collection/refs/heads/main/svgs/${data}.svg`;
                    } else return null;

                    if (!url) return null;

                    const response = await fetch(url, { referrerPolicy: 'no-referrer' });

                    if (!response.ok) {
                        console.error(`HTTP ${response.status}: Failed to load ${url}`);
                        return null;
                    }

                    const text = await response.text();

                    if (!text || !text.trim().startsWith('<svg')) {
                        console.error(`Invalid SVG content from ${url}`);
                        return null;
                    }

                    svgTextCache.set(key, text);
                    return text;
                } catch (fetchError) {
                    console.error(`Failed to fetch resource ${key}:`, fetchError);
                    return null;
                }
            })();

            pendingRequests.set(key, fetchPromise);

            try {
                svgText = await fetchPromise;
            } catch (error) {
                pendingRequests.delete(key);
                console.error(`Error loading resource ${key}:`, error);
                return null;
            } finally {
                pendingRequests.delete(key);
            }
        }

        if (!svgText) {
            return null;
        }

        const resource = AntVInfographic.loadSVGResource(svgText);

        if (!resource) {
            console.error(`loadSVGResource returned null for ${key}`);
            svgTextCache.delete(key);
            return null;
        }

        return resource;
    } catch (error) {
        console.error('Unexpected error in resource loader:', error);
        return null;
    }
});
</script>
<script>
 const infographic = new AntVInfographic.Infographic({
    container: '#container',
    width: '100%',
    height: '100%',
  });
  infographic.render(`{syntax}`);
</script>
  1. Write the HTML file named <title>-infographic.html using the Write tool
  1. Display to the user:

Note: The HTML file must include:

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.