← 返回
未分类 中文

Data Chart Builder

Create publication-ready charts from any data source (CSV, JSON, FRED API, or inline data). Supports line, bar, scatter, area-fill, indexed series, annotatio...
从任意数据源(CSV、JSON、FRED API 或内联数据)创建出版级图表,支持折线、柱状、散点、面积填充、指数序列、注释等功能。
pratyushchauhan
未分类 clawhub v1.0.0 1 版本 100000 Key: 无需
★ 1
Stars
📥 127
下载
💾 0
安装
1
版本
#latest

概述

Data Chart Builder

Build publication-ready charts from CSV, JSON, FRED, or inline data.

Quick Start

python3 scripts/chart_builder.py --config chart.json

Workflow

1. Prepare data or identify source

Options:

  • CSV file: Local or URL
  • JSON: Inline in config or external file
  • FRED: Federal Reserve series ID
  • Inline: Direct data array in config

2. Write config JSON

{
  "title": "My Chart Title",
  "series": [
    {
      "csv": "/path/to/data.csv",
      "date_col": "date",
      "value_col": "price",
      "label": "Stock Price",
      "color": "#2E86AB",
      "index": true
    }
  ],
  "output": "/tmp/my_chart.png"
}

3. Generate

python3 scripts/chart_builder.py --config my_chart.json

Config Reference

Top-level fields

FieldTypeDescription
---------
titlestringChart title
seriesarrayData series to plot (required)
outputstringOutput path (default: /tmp/chart.png)
figsize[w, h]Figure size in inches (default: [12, 7])
start_date / end_datestringFilter range (YYYY-MM-DD)
index_allboolIndex all series to 100
fillboolShade between first two series
fill_colorstringFill color (default: red)
fill_alphafloatFill opacity (default: 0.15)
hlinenumberDraw horizontal reference line
gridboolShow grid (default: true)
ylim[min, max]Y-axis limits
annotationsarrayVertical event markers

Series fields

FieldTypeDescription
---------
labelstringLegend label (required)
csvstringPath or URL to CSV
jsonstringPath to JSON file
fredstringFRED series ID
dataarrayInline data: [{"date": "...", "value": 100}, ...]
date_colstringDate column name (default: date)
value_colstringValue column name (default: value)
typestringline, bar, scatter
colorstringHex color
widthnumberLine width
stylestringLine style: -, --, -., :
indexboolIndex this series to 100
base_datestringIndex base date (default: first observation)

Annotations

{
  "date": "2008-09-15",
  "label": "Lehman Bankruptcy",
  "position": "top",
  "y": 120,
  "fontsize": 9
}

Examples

Economic comparison (FRED)

{
  "title": "USA: GDP vs Wages (1959 = 100)",
  "series": [
    {"fred": "A939RX0Q048SBEA", "label": "GDP Per Capita", "color": "#2E86AB", "index": true},
    {"fred": "COMPRNFB", "label": "Compensation Per Hour", "color": "#F18F01", "index": true}
  ],
  "start_date": "1959-01-01",
  "end_date": "1985-12-31",
  "fill": true,
  "annotations": [
    {"date": "1971-08-15", "label": "Nixon Shock", "position": "top", "y": 140},
    {"date": "1973-10-01", "label": "Oil Crisis", "position": "bottom", "y": 90}
  ],
  "output": "gdp_wages.png"
}

Stock price vs volume

{
  "title": "AAPL Price vs Volume",
  "series": [
    {"csv": "aapl.csv", "label": "Price", "color": "#2E86AB", "type": "line"},
    {"csv": "aapl.csv", "label": "Volume", "color": "#F18F01", "type": "bar", "value_col": "volume"}
  ],
  "output": "aapl_chart.png"
}

Inline data

{
  "title": "Sales Q1-Q4",
  "series": [
    {
      "label": "Revenue",
      "data": [
        {"date": "2024-01-01", "value": 100},
        {"date": "2024-04-01", "value": 120},
        {"date": "2024-07-01", "value": 140},
        {"date": "2024-10-01", "value": 180}
      ],
      "color": "#2E86AB",
      "type": "bar"
    }
  ],
  "output": "sales.png"
}

Scatter plot

{
  "title": "Height vs Weight",
  "series": [
    {"csv": "patients.csv", "label": "Male", "color": "blue", "type": "scatter", "date_col": "height", "value_col": "weight"},
    {"csv": "patients.csv", "label": "Female", "color": "red", "type": "scatter", "date_col": "height", "value_col": "weight"}
  ]
}

Tips

  • Indexing: Use "index": true on each series or "index_all": true globally to compare growth rates on equal footing
  • Colors: Use contrasting hex codes. Good pairs: #2E86AB (blue) + #F18F01 (orange), or #C73E1D (red) + #3B1F2B (dark)
  • Annotations: Alternate position: "top" and "bottom" to avoid overlap
  • Date parsing: Ensure dates are ISO format (YYYY-MM-DD) for reliable parsing
  • FRED: Find series IDs at fred.stlouisfed.org

Data Source Flexibility

SourceHow to specifyBest for
---------
Local CSV"csv": "/path/to/file.csv"Custom datasets
URL CSV"csv": "https://example.com/data.csv"API endpoints
FRED"fred": "GDPC1"Economic time series
Inline"data": [...]Small static datasets

版本历史

共 1 个版本

  • v1.0.0 当前
    2026-06-04 13:59

安全检测

腾讯云安全 (Keen)

队列中

腾讯云安全 (Sanbu)

队列中

🔗 相关推荐

Supertonic TTS

pratyushchauhan
使用Supertonic (Supertone)在设备上进行多语言文字转语音。适用于需要本地/离线TTS、语音生成、语音合成或转换的场景。
★ 2 📥 380

Conversation Video

pratyushchauhan
Generate animated conversation videos with multi-voice TTS audio and timed text overlays. Use when the user needs to (1)
★ 0 📥 88

FRED Data Viz

pratyushchauhan
用于在用户需要可视化、比较或分析经济数据时,根据美联储经济数据(FRED)生成可直接发布的对比图表。
★ 1 📥 139