SQL Dataviz: Turning SQL Query Results into Embeddable Charts

Introduction

A common path in data analysis is: SQL has already produced results, and the next step is to generate charts for colleagues or include them in reports. Hand-writing matplotlib code and then adjusting dimensions and color schemes often takes more time than writing the query itself; if you also need to integrate with sql-master and report-related Skills, you have to align the data formats and output methods yourself.

Below is an introduction to SQL Dataviz (slug: sql-dataviz) on SkillHub. It targets the step of “existing tabular/query results → charts,” using a unified ChartFactory to generate base64 PNG outputs that can be embedded in HTML, Markdown, or emails; for interactive needs, Plotly can output self-contained HTML.

What This Is

SQL Dataviz is a data-analysis category Agent Skill in the SkillHub community that transforms SQL or equivalent tabular data into production-level visualizations. According to SkillHub’s search summary, it integrates 50 types of visual objects native to Power BI, covering comparison, trend, distribution, proportion, geography, metric monitoring, AI intelligent analysis, statistical analysis, and other scenarios; charts are output as base64-encoded PNG.

Community-visible data (as provided by task clues at the time of writing): rating approximately 97114, approximately 1003 downloads. The package identifier is @indiv-yaoyao/sql-dataviz, with the current search version 1.0.0.

Official entry points (the canonical page is the SkillHub skill page; the API paths provided by the task are as follows, direct GET requests may return 405, installation and metadata are subject to the SkillHub CLI):

  • https://skillhub.cn/skills/user_64e5b706/sql-dataviz
  • https://api.skillhub.cn/user_64e5b706/sql-dataviz

It collaborates with sql-master (data fetching/SQL) and sql-report-generator (HTML reports) in the same pipeline, and can also be used standalone when working with existing DataFrame/dictionary data.

Core Features

Based on the installed SKILL.md and SkillHub description, the verifiable capabilities include:

  1. Static Charts (PNG / base64)
    Call various create_* methods (such as clustered column charts, line charts, pie charts, funnel charts, maps, and KPIs) through sql_dataviz.charts.ChartFactory, output in base64, which can be written into <img src="data:image/png;base64,..."> or decoded into .png files.

  2. Themes and Styles
    The factory-level set_theme() supports themes such as powerbi, alibaba, tencent, bytedance, etc.; you can also use ChartConfig to set width/height, DPI, titles, legends, etc.

  3. Interactive HTML (Plotly)
    scripts/interactive_charts.py provides InteractiveChartFactory and DashboardBuilder. The documentation lists 12 types of interactive charts (line, bar, pie, scatter, heatmap, funnel, area, treemap, gauge, combo, table, KPI cards, etc.), with themes including powerbi / dark / seaborn / ggplot2.

  4. Collaboration with Upstream and Downstream Skills
    The documentation describes the sql-master → sql-dataviz → sql-report-generator pipeline; it also provides a UnifiedPipeline chained example (query → interactive_chart → report).

  5. Restricted Mode Without Python Dependencies
    If dependencies cannot be installed, the Skill documentation still provides chart selection suggestions, data format descriptions, and color and design principles; it cannot generate PNG/HTML or interact with sql-master or sql-report-generator.

Installation and Activation

1. Install the Skill Package

In an environment where the SkillHub CLI is already configured, install from the community (consistent with the namespace used by the download API):

skillhub install sql-dataviz --namespace indiv-yaoyao

After successful installation, the Agent reads the skill instructions according to the general SKILL.md specification; for Cursor, Claude Code, Codex CLI, etc., if they are connected to the same local Skill directory, activation depends on their respective configurations for SkillHub installation paths. The official references/INSTALLATION.md does not separately distinguish between clients, so undocumented paths are not expanded here.

2. Install Python Dependencies (Required, otherwise no charts can be generated)

The Skill declares that dependencies must be installed before first use. The recommended one-click command is:

skillhub_install install_skill sql-dataviz

Manual method (in the Skill package directory):

pip install -r requirements.txt

The core packages listed in requirements.txt include: matplotlib, seaborn, pandas, numpy, pillow, plotly, networkx, wordcloud, scipy, etc. (see version constraints in the file). The documentation requires Python 3.8+ and pip 20.0+.

Optional capabilities (geography, treemaps, etc.) are described in references/INSTALLATION.md with additional packages such as geopandas, squarify, etc., which can be installed as needed based on scenarios.

Typical Usage

Basics: Generating a Clustered Column Chart from Tabular Data

The following snippet comes from the Skill’s quick start, demonstrating the minimal closed loop: factory → theme → data dictionary → base64 PNG.

from sql_dataviz.charts import ChartFactory

factory = ChartFactory()
factory.set_theme('powerbi')

data = {
    'categories': ['Q1', 'Q2', 'Q3', 'Q4'],
    'series': [
        {'name': '销售额', 'data': [100, 150, 120, 200]},
        {'name': '成本', 'data': [60, 80, 70, 100]}
    ]
}

chart_b64 = factory.create_clustered_column(data)
html = f'<img src="data:image/png;base64,{chart_b64}" />'

Integration with sql-master

First execute the SQL, then map the row results to categories / series, and then call ChartFactory (see the collaboration example in the Skill documentation).

Interactive HTML

from scripts.interactive_charts import InteractiveChartFactory

factory = InteractiveChartFactory(theme="powerbi")
html = factory.create_line(data)
factory.save_html(html, "chart.html")

In conversational scenarios, you can explain to the Agent “there are already SQL results / CSV, please select according to SQL Dataviz and output base64 charts or Plotly HTML,” and the Skill will constrain the selection and data shape.

Use Cases and Considerations

Who It’s For

  • Those who already use or plan to use sql-master for data fetching and need stable, embeddable chart outputs.
  • Those who want to include charts in sql-report-generator or other HTML/Markdown reports.
  • Those who want to use a unified factory API in Agent conversations instead of writing drawing code from scratch each time.

Limitations and Notes

  • When dependencies are not installed, only the “degraded” guidance in the documentation can be used, and charts cannot actually be rendered.
  • The number of chart types mentioned in different sections of the documentation varies (such as capability matrix, changelog, and requirements comments); rely on the locally installed SKILL.md and method names.
  • Some support links at the end of the Skill document are placeholder domains (example.com) and are not official support channels.
  • Real-time refresh requires manually querying the database on a schedule and redrawing; the Skill provides loop examples but does not replace specialized real-time dashboard infrastructure.

Conclusion

SQL Dataviz encapsulates “SQL/tabular results → deliverable charts” as an Agent Skill: static charts use base64 PNG, interactive scenarios use Plotly HTML, and it can form a complete analysis chain with sql-master and sql-report-generator. To pull from the community and configure the environment, you can start from the SkillHub page or the following addresses, and use skillhub install sql-dataviz --namespace indiv-yaoyao and skillhub_install install_skill sql-dataviz to complete the skill and dependency installation.

  • https://skillhub.cn/skills/user_64e5b706/sql-dataviz
  • https://api.skillhub.cn/user_64e5b706/sql-dataviz
羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

Xiaoye