@diagrammo/dgmo 0.5.1 → 0.5.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.d.cts CHANGED
@@ -546,7 +546,7 @@ declare function computeTimeTicks(domainMin: number, domainMax: number, scale: d
546
546
  * Renders a timeline chart into the given container using D3.
547
547
  * Supports horizontal (default) and vertical orientation.
548
548
  */
549
- declare function renderTimeline(container: HTMLDivElement, parsed: ParsedD3, palette: PaletteColors, isDark: boolean, onClickItem?: (lineNumber: number) => void, exportDims?: D3ExportDimensions, activeTagGroup?: string | null, swimlaneTagGroup?: string | null, onTagStateChange?: (activeTagGroup: string | null, swimlaneTagGroup: string | null) => void): void;
549
+ declare function renderTimeline(container: HTMLDivElement, parsed: ParsedD3, palette: PaletteColors, isDark: boolean, onClickItem?: (lineNumber: number) => void, exportDims?: D3ExportDimensions, activeTagGroup?: string | null, swimlaneTagGroup?: string | null, onTagStateChange?: (activeTagGroup: string | null, swimlaneTagGroup: string | null) => void, viewMode?: boolean): void;
550
550
  /**
551
551
  * Renders a word cloud into the given container using d3-cloud.
552
552
  */
package/dist/index.d.ts CHANGED
@@ -546,7 +546,7 @@ declare function computeTimeTicks(domainMin: number, domainMax: number, scale: d
546
546
  * Renders a timeline chart into the given container using D3.
547
547
  * Supports horizontal (default) and vertical orientation.
548
548
  */
549
- declare function renderTimeline(container: HTMLDivElement, parsed: ParsedD3, palette: PaletteColors, isDark: boolean, onClickItem?: (lineNumber: number) => void, exportDims?: D3ExportDimensions, activeTagGroup?: string | null, swimlaneTagGroup?: string | null, onTagStateChange?: (activeTagGroup: string | null, swimlaneTagGroup: string | null) => void): void;
549
+ declare function renderTimeline(container: HTMLDivElement, parsed: ParsedD3, palette: PaletteColors, isDark: boolean, onClickItem?: (lineNumber: number) => void, exportDims?: D3ExportDimensions, activeTagGroup?: string | null, swimlaneTagGroup?: string | null, onTagStateChange?: (activeTagGroup: string | null, swimlaneTagGroup: string | null) => void, viewMode?: boolean): void;
550
550
  /**
551
551
  * Renders a word cloud into the given container using d3-cloud.
552
552
  */
package/dist/index.js CHANGED
@@ -19416,7 +19416,7 @@ function buildEventTooltipHtml(ev) {
19416
19416
  function buildEraTooltipHtml(era) {
19417
19417
  return `<strong>${era.label}</strong><br>${formatDateLabel(era.startDate)} \u2192 ${formatDateLabel(era.endDate)}`;
19418
19418
  }
19419
- function renderTimeline(container, parsed, palette, isDark, onClickItem, exportDims, activeTagGroup, swimlaneTagGroup, onTagStateChange) {
19419
+ function renderTimeline(container, parsed, palette, isDark, onClickItem, exportDims, activeTagGroup, swimlaneTagGroup, onTagStateChange, viewMode) {
19420
19420
  d3Selection12.select(container).selectAll(":not([data-d3-tooltip])").remove();
19421
19421
  const {
19422
19422
  timelineEvents,
@@ -20181,27 +20181,35 @@ function renderTimeline(container, parsed, palette, isDark, onClickItem, exportD
20181
20181
  exportDims,
20182
20182
  currentActiveGroup,
20183
20183
  currentSwimlaneGroup,
20184
- onTagStateChange
20184
+ onTagStateChange,
20185
+ viewMode
20185
20186
  );
20186
20187
  }, drawLegend2 = function() {
20187
20188
  mainSvg.selectAll(".tl-tag-legend-group").remove();
20188
- const totalW = legendGroups.reduce((s, lg) => {
20189
+ const visibleGroups = viewMode ? legendGroups.filter(
20190
+ (lg) => currentActiveGroup != null && lg.group.name.toLowerCase() === currentActiveGroup.toLowerCase()
20191
+ ) : legendGroups;
20192
+ if (visibleGroups.length === 0) return;
20193
+ const totalW = visibleGroups.reduce((s, lg) => {
20189
20194
  const isActive = currentActiveGroup != null && lg.group.name.toLowerCase() === currentActiveGroup.toLowerCase();
20190
20195
  return s + (isActive ? lg.expandedWidth : lg.minifiedWidth);
20191
- }, 0) + (legendGroups.length - 1) * LG_GROUP_GAP;
20196
+ }, 0) + (visibleGroups.length - 1) * LG_GROUP_GAP;
20192
20197
  let cx = (width - totalW) / 2;
20193
- for (const lg of legendGroups) {
20198
+ for (const lg of visibleGroups) {
20194
20199
  const groupKey = lg.group.name.toLowerCase();
20195
20200
  const isActive = currentActiveGroup != null && currentActiveGroup.toLowerCase() === groupKey;
20196
20201
  const isSwimActive = currentSwimlaneGroup != null && currentSwimlaneGroup.toLowerCase() === groupKey;
20197
20202
  const pillLabel = lg.group.name;
20198
20203
  const pillWidth = pillLabel.length * LG_PILL_FONT_W + LG_PILL_PAD;
20199
- const gEl = mainSvg.append("g").attr("transform", `translate(${cx}, ${legendY})`).attr("class", "tl-tag-legend-group tl-tag-legend-entry").attr("data-legend-group", groupKey).attr("data-tag-group", groupKey).attr("data-legend-entry", "__group__").style("cursor", "pointer").on("click", () => {
20200
- currentActiveGroup = currentActiveGroup === groupKey ? null : groupKey;
20201
- drawLegend2();
20202
- recolorEvents2();
20203
- onTagStateChange?.(currentActiveGroup, currentSwimlaneGroup);
20204
- });
20204
+ const gEl = mainSvg.append("g").attr("transform", `translate(${cx}, ${legendY})`).attr("class", "tl-tag-legend-group tl-tag-legend-entry").attr("data-legend-group", groupKey).attr("data-tag-group", groupKey).attr("data-legend-entry", "__group__");
20205
+ if (!viewMode) {
20206
+ gEl.style("cursor", "pointer").on("click", () => {
20207
+ currentActiveGroup = currentActiveGroup === groupKey ? null : groupKey;
20208
+ drawLegend2();
20209
+ recolorEvents2();
20210
+ onTagStateChange?.(currentActiveGroup, currentSwimlaneGroup);
20211
+ });
20212
+ }
20205
20213
  if (isActive) {
20206
20214
  gEl.append("rect").attr("width", lg.expandedWidth).attr("height", LG_HEIGHT).attr("rx", LG_HEIGHT / 2).attr("fill", groupBg);
20207
20215
  }
@@ -20214,36 +20222,44 @@ function renderTimeline(container, parsed, palette, isDark, onClickItem, exportD
20214
20222
  }
20215
20223
  gEl.append("text").attr("x", pillXOff + pillWidth / 2).attr("y", LG_HEIGHT / 2 + LG_PILL_FONT_SIZE / 2 - 2).attr("font-size", LG_PILL_FONT_SIZE).attr("font-weight", "500").attr("font-family", FONT_FAMILY).attr("fill", isActive ? palette.text : palette.textMuted).attr("text-anchor", "middle").text(pillLabel);
20216
20224
  if (isActive) {
20217
- const iconX = pillXOff + pillWidth + 5;
20218
- const iconY = (LG_HEIGHT - 10) / 2;
20219
- const iconEl = drawSwimlaneIcon2(gEl, iconX, iconY, isSwimActive);
20220
- iconEl.attr("data-swimlane-toggle", groupKey).on("click", (event) => {
20221
- event.stopPropagation();
20222
- currentSwimlaneGroup = currentSwimlaneGroup === groupKey ? null : groupKey;
20223
- onTagStateChange?.(currentActiveGroup, currentSwimlaneGroup);
20224
- relayout2();
20225
- });
20226
- let entryX = pillXOff + pillWidth + LG_ICON_W + 4;
20225
+ let entryX;
20226
+ if (!viewMode) {
20227
+ const iconX = pillXOff + pillWidth + 5;
20228
+ const iconY = (LG_HEIGHT - 10) / 2;
20229
+ const iconEl = drawSwimlaneIcon2(gEl, iconX, iconY, isSwimActive);
20230
+ iconEl.attr("data-swimlane-toggle", groupKey).on("click", (event) => {
20231
+ event.stopPropagation();
20232
+ currentSwimlaneGroup = currentSwimlaneGroup === groupKey ? null : groupKey;
20233
+ onTagStateChange?.(currentActiveGroup, currentSwimlaneGroup);
20234
+ relayout2();
20235
+ });
20236
+ entryX = pillXOff + pillWidth + LG_ICON_W + 4;
20237
+ } else {
20238
+ entryX = pillXOff + pillWidth + 8;
20239
+ }
20227
20240
  for (const entry of lg.group.entries) {
20228
20241
  const tagKey = lg.group.name.toLowerCase();
20229
20242
  const tagVal = entry.value.toLowerCase();
20230
- const entryG = gEl.append("g").attr("class", "tl-tag-legend-entry").attr("data-tag-group", tagKey).attr("data-legend-entry", tagVal).style("cursor", "pointer").on("mouseenter", (event) => {
20231
- event.stopPropagation();
20232
- fadeToTagValue(mainG, tagKey, tagVal);
20233
- mainSvg.selectAll(".tl-tag-legend-entry").each(function() {
20234
- const el = d3Selection12.select(this);
20235
- const ev = el.attr("data-legend-entry");
20236
- if (ev === "__group__") return;
20237
- const eg = el.attr("data-tag-group");
20238
- el.attr("opacity", eg === tagKey && ev === tagVal ? 1 : FADE_OPACITY);
20243
+ const entryG = gEl.append("g").attr("class", "tl-tag-legend-entry").attr("data-tag-group", tagKey).attr("data-legend-entry", tagVal);
20244
+ if (!viewMode) {
20245
+ entryG.style("cursor", "pointer").on("mouseenter", (event) => {
20246
+ event.stopPropagation();
20247
+ fadeToTagValue(mainG, tagKey, tagVal);
20248
+ mainSvg.selectAll(".tl-tag-legend-entry").each(function() {
20249
+ const el = d3Selection12.select(this);
20250
+ const ev = el.attr("data-legend-entry");
20251
+ if (ev === "__group__") return;
20252
+ const eg = el.attr("data-tag-group");
20253
+ el.attr("opacity", eg === tagKey && ev === tagVal ? 1 : FADE_OPACITY);
20254
+ });
20255
+ }).on("mouseleave", (event) => {
20256
+ event.stopPropagation();
20257
+ fadeReset(mainG);
20258
+ mainSvg.selectAll(".tl-tag-legend-entry").attr("opacity", 1);
20259
+ }).on("click", (event) => {
20260
+ event.stopPropagation();
20239
20261
  });
20240
- }).on("mouseleave", (event) => {
20241
- event.stopPropagation();
20242
- fadeReset(mainG);
20243
- mainSvg.selectAll(".tl-tag-legend-entry").attr("opacity", 1);
20244
- }).on("click", (event) => {
20245
- event.stopPropagation();
20246
- });
20262
+ }
20247
20263
  entryG.append("circle").attr("cx", entryX + LG_DOT_R).attr("cy", LG_HEIGHT / 2).attr("r", LG_DOT_R).attr("fill", entry.color);
20248
20264
  const textX = entryX + LG_DOT_R * 2 + LG_ENTRY_DOT_GAP;
20249
20265
  entryG.append("text").attr("x", textX).attr("y", LG_HEIGHT / 2 + LG_ENTRY_FONT_SIZE / 2 - 1).attr("font-size", LG_ENTRY_FONT_SIZE).attr("font-family", FONT_FAMILY).attr("fill", palette.textMuted).text(entry.value);
@@ -20279,7 +20295,8 @@ function renderTimeline(container, parsed, palette, isDark, onClickItem, exportD
20279
20295
  const groupBg = isDark ? mix(palette.surface, palette.bg, 50) : mix(palette.surface, palette.bg, 30);
20280
20296
  const legendGroups = parsed.timelineTagGroups.map((g) => {
20281
20297
  const pillW = g.name.length * LG_PILL_FONT_W + LG_PILL_PAD;
20282
- let entryX = LG_CAPSULE_PAD + pillW + LG_ICON_W + 4;
20298
+ const iconSpace = viewMode ? 8 : LG_ICON_W + 4;
20299
+ let entryX = LG_CAPSULE_PAD + pillW + iconSpace;
20283
20300
  for (const entry of g.entries) {
20284
20301
  const textX = entryX + LG_DOT_R * 2 + LG_ENTRY_DOT_GAP;
20285
20302
  entryX = textX + entry.value.length * LG_ENTRY_FONT_W + LG_ENTRY_TRAIL;