Skip to content

anbeime/skill / skills/data-flow-skill/data-flow-skill

data-flow-skill

Verified

面向数据分析任务的一站式 Agent Skill,覆盖数据类型检测、数据理解、预处理、统计分析、可视化图表生成、正式报告和幻灯片输出。适用于课程作业、论文实验、业务分析、SEO/GEO 数据报告和可追溯数据分析工作流。

FileKindSize
README.mdmarkdown1.8 KB
SKILL.mdskill md7.7 KB
references/data-types.mdmarkdown907 B
references/reporting.mdmarkdown816 B
references/slides.mdmarkdown895 B
references/validation.mdmarkdown1.1 KB
references/visualization.mdmarkdown797 B
references/workflow.mdmarkdown875 B
requirements.txtmanifest97 B
scripts/README.mdmarkdown1.0 KB
scripts/analysis/__init__.pyscript35 B
scripts/analysis/analyzer_data_understanding.pyscript5.2 KB
scripts/analysis/analyzer_dataset_detection.pyscript7.6 KB
scripts/analysis/analyzer_findings_generation.pyscript57.1 KB
scripts/analysis/analyzer_preprocessing.pyscript1.9 KB
scripts/analysis/analyzer_statistical_analysis.pyscript934 B
scripts/analysis/analyzer_strategy_registry.pyscript3.4 KB
scripts/analysis/analyzer_time_series_analysis.pyscript2.0 KB
scripts/image_gen/image_generator.pyscript6.4 KB
scripts/mermaid/__init__.pyscript202 B
scripts/mermaid/cli.pyscript4.8 KB
scripts/mermaid/echarts_export.pyscript6.6 KB
scripts/mermaid/flowchart.pyscript9.4 KB
scripts/visualization/matplotlib/bar_memevolve.pyscript4.7 KB
scripts/visualization/matplotlib/bar_spice.pyscript6.0 KB
scripts/visualization/matplotlib/box_plot.pyscript4.4 KB
scripts/visualization/matplotlib/bubble_chart.pyscript5.8 KB
scripts/visualization/matplotlib/calendar_heatmap.pyscript8.2 KB
scripts/visualization/matplotlib/line_aime.pyscript3.0 KB
scripts/visualization/matplotlib/line_loss_inset.pyscript5.4 KB
scripts/visualization/matplotlib/line_selfdistill.pyscript7.0 KB
scripts/visualization/matplotlib/parallel_coordinates.pyscript6.7 KB
scripts/visualization/matplotlib/radar_dora.pyscript4.7 KB
scripts/visualization/matplotlib/scatter_break.pyscript5.8 KB
scripts/visualization/matplotlib/scatter_tsne.pyscript4.4 KB
scripts/visualization/matplotlib/stacked_bar.pyscript4.5 KB
scripts/visualization/matplotlib/violin_plot.pyscript5.3 KB

scripts/mermaid/echarts_export.py

View on GitHub
"""Export ECharts configurations to image formats."""

from __future__ import annotations

import json
import shutil
import subprocess
import tempfile
from pathlib import Path


def is_echarts_cli_available() -> bool:
    return shutil.which("npx") is not None


def render_echarts_file(
    input_path: str | Path,
    output_path: str | Path,
    *,
    format: str | None = None,
    cli_timeout_seconds: int = 60,
) -> Path:
    """Render an ECharts JSON config file to an image.

    Args:
        input_path: Path to ECharts JSON config file.
        output_path: Output image file path.
        format: Output format (png, jpeg, svg, pdf). Inferred from output_path if None.
        cli_timeout_seconds: Timeout for CLI rendering.

    Returns:
        Path to the rendered output file.
    """
    input_file = Path(input_path)
    output_file = Path(output_path)
    output_file.parent.mkdir(parents=True, exist_ok=True)

    if format is None:
        format = output_file.suffix.lstrip(".").lower()
        if not format:
            format = "png"

    if format not in {"png", "jpeg", "jpg", "svg", "pdf"}:
        raise ValueError(f"Unsupported output format: {format}")

    if format in {"jpeg", "jpg"}:
        format = "jpeg"

    if not input_file.exists():
        raise FileNotFoundError(f"Input file not found: {input_file}")

    config = json.loads(input_file.read_text(encoding="utf-8"))

    html_content = _build_echarts_html(config, format)

    with tempfile.NamedTemporaryFile(
        mode="w", suffix=".html", delete=False, encoding="utf-8"
    ) as f:
        f.write(html_content)
        temp_html = Path(f.name)

    try:
        _render_via_puppeteer(temp_html, output_file, format=format, timeout=cli_timeout_seconds)
    except FileNotFoundError:
        if shutil.which("node") is None:
            raise RuntimeError(
                "Node.js is not installed. Please install Node.js to render ECharts images."
            ) from None
        raise
    except subprocess.TimeoutExpired:
        raise RuntimeError(f"Rendering timed out after {cli_timeout_seconds} seconds.")
    except subprocess.CalledProcessError as exc:
        stderr = (exc.stderr or "").strip()
        stdout = (exc.stdout or "").strip()
        error_msg = stderr or stdout or "Unknown error"
        raise RuntimeError(f"ECharts rendering failed: {error_msg}") from exc
    finally:
        temp_html.unlink(missing_ok=True)

    return output_file


def _build_echarts_html(config: dict, format: str) -> str:
    width = config.get("width", 800)
    height = config.get("height", 600)

    config_json = json.dumps(config, ensure_ascii=False, separators=(",", ":"))

    background_color = config.get("backgroundColor", "#ffffff")

    return f"""<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <script src="https://cdn.jsdelivr.net/npm/echarts@5.4.3/dist/echarts.min.js"></script>
  <style>
    * {{ margin: 0; padding: 0; box-sizing: border-box; }}
    body {{
      background: {background_color};
      width: {width}px;
      height: {height}px;
      overflow: hidden;
    }}
    #chart {{
      width: {width}px;
      height: {height}px;
    }}
  </style>
</head>
<body>
  <div id="chart"></div>
  <script>
    var chart = echarts.init(document.getElementById('chart'), null, {{
      renderer: 'canvas',
      width: {width},
      height: {height}
    }});
    var option = {config_json};
    chart.setOption(option);

    // Export after render completes
    setTimeout(function() {{
      window._echarts_export_format = '{format}';
      window._echarts_export_done = true;
    }}, 500);
  </script>
</body>
</html>"""


def _render_via_puppeteer(
    html_path: Path,
    output_path: Path,
    *,
    format: str,
    timeout: int,
) -> None:
    script = f"""
const puppeteer = require('puppeteer');
const path = require('path');

(async () => {{
  const browser = await puppeteer.launch({{
    headless: 'new',
    args: ['--no-sandbox', '--disable-setuid-sandbox']
  }});
  const page = await browser.newPage();

  const fileUrl = 'file://' + path.resolve('{html_path}');
  await page.goto(fileUrl, {{ waitUntil: 'networkidle0', timeout: {timeout * 1000} }});

  // Wait for chart to render
  await new Promise(r => setTimeout(r, 1000));

  const chart = await page.$('#chart');
  if (!chart) throw new Error('Chart element not found');

  const boundingBox = await chart.boundingBox();

  if ('{format}' === 'svg') {{
    const svg = await page.evaluate(() => {{
      const canvas = document.querySelector('#chart canvas');
      if (!canvas) return null;
      const svgData = new XMLSerializer().serializeToString(canvas);
      return svgData;
    }});
    if (svg) {{
      require('fs').writeFileSync('{output_path}', svg);
    }} else {{
      // Fallback: get SVG directly
      const content = await page.content();
      const svgMatch = content.match(/<svg[^>]*>.*<\\/svg>/s);
      if (svgMatch) {{
        require('fs').writeFileSync('{output_path}', svgMatch[0]);
      }} else {{
        throw new Error('SVG export not supported for this chart type');
      }}
    }}
  }} else {{
    await page.setViewport({{
      width: Math.ceil(boundingBox.width),
      height: Math.ceil(boundingBox.height)
    }});

    await page.evaluate(() => {{
      const chartInst = document.querySelector('#chart canvas');
      if (chartInst && chartInst.style) {{
        chartInst.style.background = 'white';
      }}
    }});

    const screenshotOptions = {{
      path: '{output_path}',
      type: '{format}',
      fullPage: false,
      clip: {{
        x: boundingBox.x,
        y: boundingBox.y,
        width: boundingBox.width,
        height: boundingBox.height
      }}
    }};

    if ('{format}' === 'jpeg' || '{format}' === 'jpg') {{
      screenshotOptions.type = 'jpeg';
      screenshotOptions.quality = 95;
    }}

    await page.screenshot(screenshotOptions);
  }}

  await browser.close();
  process.exit(0);
}})().catch(err => {{
  console.error(err);
  process.exit(1);
}});
"""

    with tempfile.NamedTemporaryFile(
        mode="w", suffix=".js", delete=False, encoding="utf-8"
    ) as f:
        f.write(script)
        script_path = Path(f.name)

    try:
        result = subprocess.run(
            ["node", str(script_path)],
            capture_output=True,
            text=True,
            timeout=timeout,
        )
        if result.returncode != 0:
            stderr = result.stderr.strip()
            stdout = result.stdout.strip()
            error_msg = stderr or stdout or "Unknown error"
            raise RuntimeError(f"Puppeteer rendering failed: {error_msg}")
    finally:
        script_path.unlink(missing_ok=True)
reverse-engineer-anythingmorluto/reaReverse engineer native, managed, Electron/JavaScript, packaged, firmware, and browser targets with REA, and build agent environments (AgentEnv bundles) of web applications from a live instance or a capture, and of Linux desktop apps with a task from a request. Use shipped-artifact or requested runtime evidence to explain features, compare versions, decompile code, or guide a reconstruction. Skip REA for ordinary source-repository architecture analysis.Stars: 469kUpdated Claude CodeCodexVerifiedInstall
diagnosing-superpowersobra/superpowersUse when a superpowers session went wrong and your human partner wants to know why — repeated work, ignored plans, stumbles, poor results, a skill that didn't fire, "it took too long", "why is it so expensive", "what is it doing" — or wants to build a bug report for the superpowers maintainers, for the current session or a past one identified by id or path, on any harness.Stars: 321kUpdated Claude CodeCodexVerifiedInstall
dispatching-parallel-agentsobra/superpowersUse when facing 2+ independent tasks that can be worked on without shared state or sequential dependenciesStars: 321kUpdated Claude CodeCodexVerifiedInstall
executing-plansobra/superpowersUse when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is availableStars: 321kUpdated Claude CodeCodexVerifiedInstall