sketchmark 0.2.2 → 0.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -13,7 +13,7 @@ export declare function chartLayout(c: {
13
13
  y: number;
14
14
  w: number;
15
15
  h: number;
16
- title?: string;
16
+ label?: string;
17
17
  }): ChartLayout;
18
18
  export interface BarLineSeries {
19
19
  name: string;
@@ -84,7 +84,7 @@ export interface SceneNote {
84
84
  export interface SceneChart {
85
85
  id: string;
86
86
  chartType: string;
87
- title?: string;
87
+ label?: string;
88
88
  data: {
89
89
  headers: string[];
90
90
  rows: (string | number)[][];
@@ -851,7 +851,7 @@ var AIDiagram = (function (exports) {
851
851
  kind: "chart",
852
852
  id,
853
853
  chartType: chartType.replace("-chart", ""),
854
- title: props.title,
854
+ label: props.label ?? props.title,
855
855
  data: { headers, rows },
856
856
  width: props.width ? parseFloat(props.width) : undefined,
857
857
  height: props.height ? parseFloat(props.height) : undefined,
@@ -1343,7 +1343,7 @@ var AIDiagram = (function (exports) {
1343
1343
  return {
1344
1344
  id: c.id,
1345
1345
  chartType: c.chartType,
1346
- title: c.title,
1346
+ label: c.label,
1347
1347
  data: c.data,
1348
1348
  style: { ...ast.styles[c.id], ...themeStyle, ...c.style },
1349
1349
  x: 0,
@@ -2078,7 +2078,7 @@ var AIDiagram = (function (exports) {
2078
2078
  '#7F77DD', '#D4537E', '#639922', '#E24B4A',
2079
2079
  ];
2080
2080
  function chartLayout(c) {
2081
- const titleH = c.title ? 24 : 8;
2081
+ const titleH = c.label ? 24 : 8;
2082
2082
  const padL = 44, padR = 12, padB = 28, padT = 6;
2083
2083
  const pw = c.w - padL - padR;
2084
2084
  const ph = c.h - titleH - padT - padB;
@@ -2266,17 +2266,17 @@ var AIDiagram = (function (exports) {
2266
2266
  ...(s.strokeDash ? { strokeLineDash: s.strokeDash } : {}),
2267
2267
  }));
2268
2268
  // Title
2269
- if (c.title) {
2270
- cg.appendChild(mkT(c.title, c.x + c.w / 2, c.y + 14, cFontSize, cFontWeight, lc, 'middle', cFont));
2269
+ if (c.label) {
2270
+ cg.appendChild(mkT(c.label, c.x + c.w / 2, c.y + 14, cFontSize, cFontWeight, lc, 'middle', cFont));
2271
2271
  }
2272
2272
  const { px, py, pw, ph, cx, cy } = chartLayout(c);
2273
2273
  // ── Pie / Donut ──────────────────────────────────────────
2274
2274
  if (c.chartType === 'pie' || c.chartType === 'donut') {
2275
2275
  const { segments, total } = parsePie(c.data);
2276
- const r = Math.min(c.w * 0.38, (c.h - (c.title ? 24 : 8)) * 0.44);
2276
+ const r = Math.min(c.w * 0.38, (c.h - (c.label ? 24 : 8)) * 0.44);
2277
2277
  const ir = c.chartType === 'donut' ? r * 0.48 : 0;
2278
2278
  const legendX = c.x + 8;
2279
- const legendY = c.y + (c.title ? 28 : 12);
2279
+ const legendY = c.y + (c.label ? 28 : 12);
2280
2280
  let angle = -Math.PI / 2;
2281
2281
  for (const seg of segments) {
2282
2282
  const sweep = (seg.value / total) * Math.PI * 2;
@@ -2314,7 +2314,7 @@ var AIDiagram = (function (exports) {
2314
2314
  strokeWidth: 1.2,
2315
2315
  }));
2316
2316
  });
2317
- legend(cg, pts.map(p => p.label), CHART_COLORS, c.x + 8, c.y + (c.title ? 28 : 12), lc, cFont);
2317
+ legend(cg, pts.map(p => p.label), CHART_COLORS, c.x + 8, c.y + (c.label ? 28 : 12), lc, cFont);
2318
2318
  return cg;
2319
2319
  }
2320
2320
  // ── Bar / Line / Area ─────────────────────────────────────
@@ -5761,23 +5761,23 @@ var AIDiagram = (function (exports) {
5761
5761
  ...(s.strokeDash ? { strokeLineDash: s.strokeDash } : {}),
5762
5762
  });
5763
5763
  // Title
5764
- if (c.title) {
5764
+ if (c.label) {
5765
5765
  ctx.save();
5766
5766
  ctx.font = `${cFontWeight} ${cFontSize}px ${cFont}`;
5767
5767
  ctx.fillStyle = lc;
5768
5768
  ctx.textAlign = 'center';
5769
5769
  ctx.textBaseline = 'middle';
5770
- ctx.fillText(c.title, c.x + c.w / 2, c.y + 14);
5770
+ ctx.fillText(c.label, c.x + c.w / 2, c.y + 14);
5771
5771
  ctx.restore();
5772
5772
  }
5773
5773
  const { px, py, pw, ph, cx, cy } = chartLayout(c);
5774
5774
  // ── Pie / Donut ──────────────────────────────────────────
5775
5775
  if (c.chartType === 'pie' || c.chartType === 'donut') {
5776
5776
  const { segments, total } = parsePie(c.data);
5777
- const r = Math.min(c.w * 0.38, (c.h - (c.title ? 24 : 8)) * 0.44);
5777
+ const r = Math.min(c.w * 0.38, (c.h - (c.label ? 24 : 8)) * 0.44);
5778
5778
  const ir = c.chartType === 'donut' ? r * 0.48 : 0;
5779
5779
  const legendX = c.x + 8;
5780
- const legendY = c.y + (c.title ? 28 : 12);
5780
+ const legendY = c.y + (c.label ? 28 : 12);
5781
5781
  let angle = -Math.PI / 2;
5782
5782
  segments.forEach((seg, i) => {
5783
5783
  const sweep = (seg.value / total) * Math.PI * 2;
@@ -5805,7 +5805,7 @@ var AIDiagram = (function (exports) {
5805
5805
  strokeWidth: 1.2,
5806
5806
  });
5807
5807
  });
5808
- drawLegend(ctx, pts.map(p => p.label), CHART_COLORS, c.x + 8, c.y + (c.title ? 28 : 12), lc, cFont);
5808
+ drawLegend(ctx, pts.map(p => p.label), CHART_COLORS, c.x + 8, c.y + (c.label ? 28 : 12), lc, cFont);
5809
5809
  ctx.globalAlpha = 1;
5810
5810
  return;
5811
5811
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sketchmark",
3
- "version": "0.2.2",
3
+ "version": "0.2.3",
4
4
  "description": "A plain-text DSL for hand-drawn diagrams. Write boxes, edges, and groups as code — renders sketchy SVG/Canvas via rough.js with a built-in step-by-step animation system.",
5
5
  "keywords": [
6
6
  "diagram",