Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added fonts/AlibabaPuHuiTi-3-55-Regular.otf
Binary file not shown.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "mcp-echarts",
"description": "❤️ Generate visual charts using Apache ECharts with AI MCP dynamically.",
"version": "0.1.0",
"version": "0.2.0",
"main": "build/index.js",
"scripts": {
"test": "vitest",
Expand All @@ -14,11 +14,11 @@
"bin": {
"mcp-echarts": "./build/index.js"
},
"files": ["build"],
"files": ["build", "fonts"],
"keywords": ["mcp", "echarts", "visualization", "chart", "mcp-echarts"],
"dependencies": {
"@modelcontextprotocol/sdk": "^1.12.0",
"canvas": "3.1.2",
"@napi-rs/canvas": "^0.1.73",
"echarts": "^5.6.0",
"zod": "^3.25.16"
},
Expand Down
13 changes: 12 additions & 1 deletion src/utils/render.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,18 @@
import { createCanvas } from "canvas";
import path from "node:path";
import { GlobalFonts, createCanvas } from "@napi-rs/canvas";
import * as echarts from "echarts";
import type { EChartsOption } from "echarts";

const fontPath = path.join(
__dirname,
"..",
"..",
"fonts",
"AlibabaPuHuiTi-3-55-Regular.otf",
);

GlobalFonts.registerFromPath(fontPath, "sans-serif");

export function renderECharts(
echartsOption: EChartsOption,
width = 800,
Expand Down
Loading