@diagrammo/dgmo 0.8.0 → 0.8.2

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.
package/dist/index.js CHANGED
@@ -5655,10 +5655,10 @@ function buildScatterOption(parsed, palette, textColor, axisLineColor, gridOpaci
5655
5655
  };
5656
5656
  let series;
5657
5657
  if (hasCategories) {
5658
- const categories = [
5658
+ const categories2 = [
5659
5659
  ...new Set(points.map((p) => p.category).filter(Boolean))
5660
5660
  ];
5661
- series = categories.map((category, catIndex) => {
5661
+ series = categories2.map((category, catIndex) => {
5662
5662
  const categoryPoints = points.filter((p) => p.category === category);
5663
5663
  const catColor = parsed.categoryColors?.[category] ?? colors[catIndex % colors.length];
5664
5664
  const data = categoryPoints.map((p) => ({
@@ -5725,18 +5725,18 @@ function buildScatterOption(parsed, palette, textColor, axisLineColor, gridOpaci
5725
5725
  const axisYMax = Math.ceil(yMax + yPad);
5726
5726
  const gridLeft = parsed.ylabel ? 12 : 3;
5727
5727
  const gridRight = 4;
5728
- const gridBottom = parsed.xlabel ? 10 : 3;
5728
+ const gridBottom = hasCategories ? 15 : parsed.xlabel ? 10 : 3;
5729
5729
  const gridTop = parsed.title ? 15 : 5;
5730
5730
  let graphic;
5731
5731
  if (showLabels && points.length > 0) {
5732
5732
  const labelPoints = [];
5733
5733
  if (hasCategories) {
5734
- const categories = [
5734
+ const categories2 = [
5735
5735
  ...new Set(points.map((p) => p.category).filter(Boolean))
5736
5736
  ];
5737
5737
  for (let idx = 0; idx < points.length; idx++) {
5738
5738
  const pt = points[idx];
5739
- const catIndex = pt.category ? categories.indexOf(pt.category) : -1;
5739
+ const catIndex = pt.category ? categories2.indexOf(pt.category) : -1;
5740
5740
  const catColor = pt.category ? parsed.categoryColors?.[pt.category] ?? colors[catIndex % colors.length] : colors[idx % colors.length];
5741
5741
  const color = pt.color ?? catColor;
5742
5742
  const { px, py } = dataToPixel(
@@ -5785,9 +5785,12 @@ function buildScatterOption(parsed, palette, textColor, axisLineColor, gridOpaci
5785
5785
  bg
5786
5786
  );
5787
5787
  }
5788
+ const categories = hasCategories ? [...new Set(points.map((p) => p.category).filter(Boolean))] : [];
5789
+ const legendConfig = categories.length > 0 ? { data: categories, bottom: 10, textStyle: { color: textColor } } : void 0;
5788
5790
  return {
5789
5791
  ...CHART_BASE,
5790
5792
  title: titleConfig,
5793
+ ...legendConfig && { legend: legendConfig },
5791
5794
  tooltip,
5792
5795
  grid: {
5793
5796
  left: `${gridLeft}%`,
@@ -6165,11 +6168,6 @@ function buildBarOption(parsed, textColor, axisLineColor, splitLineColor, gridOp
6165
6168
  return {
6166
6169
  ...CHART_BASE,
6167
6170
  title: titleConfig,
6168
- tooltip: {
6169
- trigger: "axis",
6170
- ...tooltipTheme,
6171
- axisPointer: { type: "shadow" }
6172
- },
6173
6171
  grid: makeChartGrid({ xLabel, yLabel, hasTitle: !!parsed.title }),
6174
6172
  xAxis: isHorizontal ? valueAxis : categoryAxis,
6175
6173
  yAxis: isHorizontal ? categoryAxis : valueAxis,
@@ -6504,11 +6502,6 @@ function buildBarStackedOption(parsed, textColor, axisLineColor, splitLineColor,
6504
6502
  return {
6505
6503
  ...CHART_BASE,
6506
6504
  title: titleConfig,
6507
- tooltip: {
6508
- trigger: "axis",
6509
- ...tooltipTheme,
6510
- axisPointer: { type: "shadow" }
6511
- },
6512
6505
  legend: {
6513
6506
  data: seriesNames,
6514
6507
  bottom: 10,
@@ -24754,6 +24747,14 @@ function parseVisualization(content, palette) {
24754
24747
  if (result.type === "wordcloud") {
24755
24748
  if (colonIndex === -1 && !line10.includes(" ")) {
24756
24749
  result.words.push({ text: line10, weight: 10, lineNumber });
24750
+ } else if (colonIndex === -1) {
24751
+ const lastSpace = line10.lastIndexOf(" ");
24752
+ const maybeWeight = lastSpace >= 0 ? parseFloat(line10.substring(lastSpace + 1)) : NaN;
24753
+ if (lastSpace >= 0 && !isNaN(maybeWeight) && maybeWeight > 0) {
24754
+ result.words.push({ text: line10.substring(0, lastSpace).trim(), weight: maybeWeight, lineNumber });
24755
+ } else {
24756
+ freeformLines.push(line10);
24757
+ }
24757
24758
  } else {
24758
24759
  freeformLines.push(line10);
24759
24760
  }
@@ -26613,7 +26614,7 @@ function renderWordCloud(container, parsed, palette, _isDark, onClickItem, expor
26613
26614
  const range = maxWeight - minWeight || 1;
26614
26615
  const fontSize = (weight) => {
26615
26616
  const t = (weight - minWeight) / range;
26616
- return minSize + t * (maxSize - minSize);
26617
+ return minSize + Math.sqrt(t) * (maxSize - minSize);
26617
26618
  };
26618
26619
  const rotateFn = getRotateFn(cloudOptions.rotate);
26619
26620
  renderChartTitle(svg, title, parsed.titleLineNumber, width, textColor, onClickItem);
@@ -26621,7 +26622,7 @@ function renderWordCloud(container, parsed, palette, _isDark, onClickItem, expor
26621
26622
  "transform",
26622
26623
  `translate(${width / 2},${titleHeight + cloudHeight / 2})`
26623
26624
  );
26624
- cloud().size([width, cloudHeight]).words(words.map((w) => ({ ...w, size: fontSize(w.weight) }))).padding(4).rotate(rotateFn).fontSize((d) => d.size).font(FONT_FAMILY).on("end", (layoutWords) => {
26625
+ cloud().size([width, cloudHeight]).words(words.map((w) => ({ ...w, size: fontSize(w.weight) }))).padding(2).rotate(rotateFn).fontSize((d) => d.size).font(FONT_FAMILY).on("end", (layoutWords) => {
26625
26626
  g.selectAll("text").data(layoutWords).join("text").style("font-size", (d) => `${d.size}px`).style("font-family", FONT_FAMILY).style("font-weight", "600").style("fill", (_d, i) => colors[i % colors.length]).style(
26626
26627
  "cursor",
26627
26628
  (d) => onClickItem && d.lineNumber ? "pointer" : "default"
@@ -26663,7 +26664,7 @@ function renderWordCloudAsync(container, parsed, palette, _isDark, exportDims) {
26663
26664
  const range = maxWeight - minWeight || 1;
26664
26665
  const fontSize = (weight) => {
26665
26666
  const t = (weight - minWeight) / range;
26666
- return minSize + t * (maxSize - minSize);
26667
+ return minSize + Math.sqrt(t) * (maxSize - minSize);
26667
26668
  };
26668
26669
  const rotateFn = getRotateFn(cloudOptions.rotate);
26669
26670
  const svg = d3Selection13.select(container).append("svg").attr("width", width).attr("height", height).style("background", bgColor);
@@ -26672,7 +26673,7 @@ function renderWordCloudAsync(container, parsed, palette, _isDark, exportDims) {
26672
26673
  "transform",
26673
26674
  `translate(${width / 2},${titleHeight + cloudHeight / 2})`
26674
26675
  );
26675
- cloud().size([width, cloudHeight]).words(words.map((w) => ({ ...w, size: fontSize(w.weight) }))).padding(4).rotate(rotateFn).fontSize((d) => d.size).font(FONT_FAMILY).on("end", (layoutWords) => {
26676
+ cloud().size([width, cloudHeight]).words(words.map((w) => ({ ...w, size: fontSize(w.weight) }))).padding(2).rotate(rotateFn).fontSize((d) => d.size).font(FONT_FAMILY).on("end", (layoutWords) => {
26676
26677
  g.selectAll("text").data(layoutWords).join("text").style("font-size", (d) => `${d.size}px`).style("font-family", FONT_FAMILY).style("font-weight", "600").style("fill", (_d, i) => colors[i % colors.length]).attr("text-anchor", "middle").attr(
26677
26678
  "transform",
26678
26679
  (d) => `translate(${d.x},${d.y}) rotate(${d.rotate})`