ztd-charts-cli 0.6.0 → 0.7.0

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.
Files changed (42) hide show
  1. package/README.md +1 -1
  2. package/dist/api.js +1 -1
  3. package/dist/{chunk-4K4P2AWW.js → chunk-4WXNLD5P.js} +29 -6
  4. package/dist/cli.js +1 -1
  5. package/dist/client/area.js +9 -9
  6. package/dist/client/bar.js +10 -10
  7. package/dist/client/beeswarm.js +10 -10
  8. package/dist/client/box.js +10 -10
  9. package/dist/client/bubble.js +10 -10
  10. package/dist/client/bullet.js +10 -10
  11. package/dist/client/bump.js +10 -10
  12. package/dist/client/calendar.js +10 -10
  13. package/dist/client/candlestick.js +10 -10
  14. package/dist/client/chord.js +10 -10
  15. package/dist/client/donut.js +10 -10
  16. package/dist/client/dumbbell.js +10 -10
  17. package/dist/client/funnel.js +10 -10
  18. package/dist/client/gauge.js +10 -10
  19. package/dist/client/heatmap.js +10 -10
  20. package/dist/client/histogram.js +10 -10
  21. package/dist/client/line.js +9 -9
  22. package/dist/client/lollipop.js +10 -10
  23. package/dist/client/marimekko.js +10 -10
  24. package/dist/client/parallel.js +10 -10
  25. package/dist/client/pareto.js +10 -10
  26. package/dist/client/pie.js +10 -10
  27. package/dist/client/radar.js +10 -10
  28. package/dist/client/radialBar.js +10 -10
  29. package/dist/client/ridgeline.js +10 -10
  30. package/dist/client/sankey.js +10 -10
  31. package/dist/client/scatter.js +10 -10
  32. package/dist/client/segmented.js +10 -10
  33. package/dist/client/skyline.js +10 -10
  34. package/dist/client/slope.js +10 -10
  35. package/dist/client/sparkline.js +10 -10
  36. package/dist/client/stream.js +9 -9
  37. package/dist/client/sunburst.js +10 -10
  38. package/dist/client/tileMap.js +28 -0
  39. package/dist/client/treemap.js +9 -9
  40. package/dist/client/waffle.js +10 -10
  41. package/dist/client/waterfall.js +10 -10
  42. package/package.json +2 -2
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # ztd-charts-cli
2
2
 
3
- `ztd-charts`: the list of all 36 charts, JSON Schema, spec validation, SVG/PNG/HTML rendering, starter files, and chart suggestions from your data.
3
+ `ztd-charts`: the list of all 37 charts, JSON Schema, spec validation, SVG/PNG/HTML rendering, starter files, and chart suggestions from your data.
4
4
 
5
5
  [Website](https://charts.ztd.app) · [Gallery](https://charts.ztd.app/docs/) · [GitHub](https://github.com/Junhan2/ztd-charts)
6
6
 
package/dist/api.js CHANGED
@@ -18,7 +18,7 @@ import {
18
18
  summarize,
19
19
  svgToPng,
20
20
  validate
21
- } from "./chunk-4K4P2AWW.js";
21
+ } from "./chunk-4WXNLD5P.js";
22
22
  export {
23
23
  CHARTS,
24
24
  FETCH_TIMEOUT_MS,
@@ -3,16 +3,16 @@ import { existsSync, readFileSync, readdirSync } from "fs";
3
3
  import { createRequire } from "module";
4
4
  import { dirname, join, resolve } from "path";
5
5
  import { fileURLToPath } from "url";
6
- import { CHARTS, commonOptionsIn, downloadFields, findGroup, findLevel, getChartDef, localizeDef, schemaForIn, specLocale, specSchemaIn, specTemplate, suggestCharts, validateSpec, variantsIn, TYPE_ALIASES } from "ztd-charts/spec";
6
+ import { CHARTS, commonOptionsIn, downloadFields, FACET_TYPES, findGroup, findLevel, getChartDef, localizeDef, schemaForIn, specLocale, specSchemaIn, specTemplate, suggestCharts, validateSpec, variantsIn, TYPE_ALIASES } from "ztd-charts/spec";
7
7
  import { inlineRows, normalizeData, parseCSV } from "ztd-charts/spec";
8
8
  import { langOf, renderSpecToHTML, renderSpecToSVG, resolveDef, resolveSpecData } from "ztd-charts/server";
9
9
 
10
10
  // src/messages.ts
11
11
  import { plural } from "ztd-charts/server";
12
- var VERSION = "0.6.0";
12
+ var VERSION = "0.7.0";
13
13
  var SCHEMA_URL = "https://unpkg.com/ztd-charts/schema/chart-spec.schema.json";
14
14
  var en = {
15
- help: `ztd-charts ${VERSION} CLI for 36 React chart types
15
+ help: `ztd-charts ${VERSION} CLI for 37 React chart types
16
16
 
17
17
  Usage
18
18
  ztd-charts list [--group proportion] [--level basic] [--json]
@@ -103,7 +103,7 @@ ${n} charts. Details: ztd-charts info <type>`,
103
103
  })
104
104
  };
105
105
  var ko = {
106
- help: `ztd-charts ${VERSION} React \uCC28\uD2B8 36\uC885\uC744 \uC704\uD55C CLI
106
+ help: `ztd-charts ${VERSION} React \uCC28\uD2B8 37\uC885\uC744 \uC704\uD55C CLI
107
107
 
108
108
  \uC0AC\uC6A9\uBC95
109
109
  ztd-charts list [--group \uBE44\uC728] [--level \uAE30\uBCF8] [--json]
@@ -274,6 +274,28 @@ function jsxValue(v) {
274
274
  return typeof v === "string" && j === `"${v}"` && !v.includes("&") ? j : `{${j}}`;
275
275
  }
276
276
  var JSX_NAME = /^[A-Za-z_$][\w$-]*$/;
277
+ function facetElement(component, type, facet, props) {
278
+ const own = [props[0]];
279
+ const fields = [];
280
+ for (const p of props.slice(1)) {
281
+ const at = p.indexOf("=");
282
+ const name = p.slice(0, at);
283
+ const value = p.slice(at + 1);
284
+ if (name === "highlight") own.push(p);
285
+ else fields.push(`${/^[A-Za-z_$][\w$]*$/.test(name) ? name : JSON.stringify(name)}: ${value.startsWith("{") ? value.slice(1, -1) : value}`);
286
+ }
287
+ const { columns, scale } = facet;
288
+ const head = [
289
+ `chart={${component}}`,
290
+ `type=${jsxValue(type)}`,
291
+ own[0],
292
+ `by=${jsxValue(facet.by)}`,
293
+ ...Number.isInteger(columns) && columns >= 1 ? [`columns=${jsxValue(columns)}`] : [],
294
+ ...scale === "shared" || scale === "free" ? [`scale=${jsxValue(scale)}`] : [],
295
+ ...own.slice(1)
296
+ ];
297
+ return `<ChartFacets ${head.join(" ")} chartProps={{ ${fields.join(", ")} }} />`;
298
+ }
277
299
  function reactSnippet(spec, opts = {}) {
278
300
  const ko2 = langOf(opts.locale) === "ko";
279
301
  const def = resolveType(spec.type);
@@ -292,9 +314,10 @@ function reactSnippet(spec, opts = {}) {
292
314
  if (k === "tooltip" && template) props.push(`tooltip={templateTooltip(${JSON.stringify(template)}${tipLocale ? `, ${JSON.stringify(tipLocale)}` : ""})}`);
293
315
  else props.push(`${k}=${jsxValue(v)}`);
294
316
  }
295
- const chartEl = `<${def.component} ${props.join(" ")} />`;
317
+ const facet = spec.facet && typeof spec.facet.by === "string" && FACET_TYPES.includes(def.type) && !(def.type === "bar" && spec.options?.layout === "diverging") ? spec.facet : void 0;
318
+ const chartEl = facet ? facetElement(def.component, def.type, facet, props) : `<${def.component} ${props.join(" ")} />`;
296
319
  const card = spec.card;
297
- const imports = [card && "ChartCard", card?.download && "DownloadButtons", def.component, template && "templateTooltip"].filter(Boolean).join(", ");
320
+ const imports = [card && "ChartCard", card?.download && "DownloadButtons", facet && "ChartFacets", def.component, template && "templateTooltip"].filter(Boolean).join(", ");
298
321
  const more = rows && rows.length > 12 ? ko2 ? ` // \uC678 ${rows.length - 12}\uD589` : ` // and ${rows.length - 12} more rows` : "";
299
322
  const dataLine = rows && opts.inlineData !== false ? `const ${dataVar} = ${JSON.stringify(rows.slice(0, 12), null, 2)}${more};
300
323
 
package/dist/cli.js CHANGED
@@ -13,7 +13,7 @@ import {
13
13
  resolveType,
14
14
  suggest,
15
15
  validate
16
- } from "./chunk-4K4P2AWW.js";
16
+ } from "./chunk-4WXNLD5P.js";
17
17
 
18
18
  // src/cli.ts
19
19
  import { existsSync, mkdirSync, readFileSync, writeFileSync } from "fs";