@diagrammo/dgmo 0.5.1 → 0.5.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.
- package/dist/cli.cjs +123 -123
- package/dist/index.cjs +58 -40
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +58 -40
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/d3.ts +85 -54
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,36 @@ 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
|
|
20189
|
-
|
|
20189
|
+
const effectiveColorKey = (currentActiveGroup ?? currentSwimlaneGroup)?.toLowerCase() ?? null;
|
|
20190
|
+
const visibleGroups = viewMode ? legendGroups.filter(
|
|
20191
|
+
(lg) => effectiveColorKey != null && lg.group.name.toLowerCase() === effectiveColorKey
|
|
20192
|
+
) : legendGroups;
|
|
20193
|
+
if (visibleGroups.length === 0) return;
|
|
20194
|
+
const totalW = visibleGroups.reduce((s, lg) => {
|
|
20195
|
+
const isActive = viewMode || currentActiveGroup != null && lg.group.name.toLowerCase() === currentActiveGroup.toLowerCase();
|
|
20190
20196
|
return s + (isActive ? lg.expandedWidth : lg.minifiedWidth);
|
|
20191
|
-
}, 0) + (
|
|
20197
|
+
}, 0) + (visibleGroups.length - 1) * LG_GROUP_GAP;
|
|
20192
20198
|
let cx = (width - totalW) / 2;
|
|
20193
|
-
for (const lg of
|
|
20199
|
+
for (const lg of visibleGroups) {
|
|
20194
20200
|
const groupKey = lg.group.name.toLowerCase();
|
|
20195
|
-
const isActive = currentActiveGroup != null && currentActiveGroup.toLowerCase() === groupKey;
|
|
20201
|
+
const isActive = viewMode || currentActiveGroup != null && currentActiveGroup.toLowerCase() === groupKey;
|
|
20196
20202
|
const isSwimActive = currentSwimlaneGroup != null && currentSwimlaneGroup.toLowerCase() === groupKey;
|
|
20197
20203
|
const pillLabel = lg.group.name;
|
|
20198
20204
|
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__")
|
|
20200
|
-
|
|
20201
|
-
|
|
20202
|
-
|
|
20203
|
-
|
|
20204
|
-
|
|
20205
|
+
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__");
|
|
20206
|
+
if (!viewMode) {
|
|
20207
|
+
gEl.style("cursor", "pointer").on("click", () => {
|
|
20208
|
+
currentActiveGroup = currentActiveGroup === groupKey ? null : groupKey;
|
|
20209
|
+
drawLegend2();
|
|
20210
|
+
recolorEvents2();
|
|
20211
|
+
onTagStateChange?.(currentActiveGroup, currentSwimlaneGroup);
|
|
20212
|
+
});
|
|
20213
|
+
}
|
|
20205
20214
|
if (isActive) {
|
|
20206
20215
|
gEl.append("rect").attr("width", lg.expandedWidth).attr("height", LG_HEIGHT).attr("rx", LG_HEIGHT / 2).attr("fill", groupBg);
|
|
20207
20216
|
}
|
|
@@ -20214,36 +20223,44 @@ function renderTimeline(container, parsed, palette, isDark, onClickItem, exportD
|
|
|
20214
20223
|
}
|
|
20215
20224
|
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
20225
|
if (isActive) {
|
|
20217
|
-
|
|
20218
|
-
|
|
20219
|
-
|
|
20220
|
-
|
|
20221
|
-
|
|
20222
|
-
|
|
20223
|
-
|
|
20224
|
-
|
|
20225
|
-
|
|
20226
|
-
|
|
20226
|
+
let entryX;
|
|
20227
|
+
if (!viewMode) {
|
|
20228
|
+
const iconX = pillXOff + pillWidth + 5;
|
|
20229
|
+
const iconY = (LG_HEIGHT - 10) / 2;
|
|
20230
|
+
const iconEl = drawSwimlaneIcon2(gEl, iconX, iconY, isSwimActive);
|
|
20231
|
+
iconEl.attr("data-swimlane-toggle", groupKey).on("click", (event) => {
|
|
20232
|
+
event.stopPropagation();
|
|
20233
|
+
currentSwimlaneGroup = currentSwimlaneGroup === groupKey ? null : groupKey;
|
|
20234
|
+
onTagStateChange?.(currentActiveGroup, currentSwimlaneGroup);
|
|
20235
|
+
relayout2();
|
|
20236
|
+
});
|
|
20237
|
+
entryX = pillXOff + pillWidth + LG_ICON_W + 4;
|
|
20238
|
+
} else {
|
|
20239
|
+
entryX = pillXOff + pillWidth + 8;
|
|
20240
|
+
}
|
|
20227
20241
|
for (const entry of lg.group.entries) {
|
|
20228
20242
|
const tagKey = lg.group.name.toLowerCase();
|
|
20229
20243
|
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)
|
|
20231
|
-
|
|
20232
|
-
|
|
20233
|
-
|
|
20234
|
-
|
|
20235
|
-
|
|
20236
|
-
|
|
20237
|
-
|
|
20238
|
-
|
|
20244
|
+
const entryG = gEl.append("g").attr("class", "tl-tag-legend-entry").attr("data-tag-group", tagKey).attr("data-legend-entry", tagVal);
|
|
20245
|
+
if (!viewMode) {
|
|
20246
|
+
entryG.style("cursor", "pointer").on("mouseenter", (event) => {
|
|
20247
|
+
event.stopPropagation();
|
|
20248
|
+
fadeToTagValue(mainG, tagKey, tagVal);
|
|
20249
|
+
mainSvg.selectAll(".tl-tag-legend-entry").each(function() {
|
|
20250
|
+
const el = d3Selection12.select(this);
|
|
20251
|
+
const ev = el.attr("data-legend-entry");
|
|
20252
|
+
if (ev === "__group__") return;
|
|
20253
|
+
const eg = el.attr("data-tag-group");
|
|
20254
|
+
el.attr("opacity", eg === tagKey && ev === tagVal ? 1 : FADE_OPACITY);
|
|
20255
|
+
});
|
|
20256
|
+
}).on("mouseleave", (event) => {
|
|
20257
|
+
event.stopPropagation();
|
|
20258
|
+
fadeReset(mainG);
|
|
20259
|
+
mainSvg.selectAll(".tl-tag-legend-entry").attr("opacity", 1);
|
|
20260
|
+
}).on("click", (event) => {
|
|
20261
|
+
event.stopPropagation();
|
|
20239
20262
|
});
|
|
20240
|
-
}
|
|
20241
|
-
event.stopPropagation();
|
|
20242
|
-
fadeReset(mainG);
|
|
20243
|
-
mainSvg.selectAll(".tl-tag-legend-entry").attr("opacity", 1);
|
|
20244
|
-
}).on("click", (event) => {
|
|
20245
|
-
event.stopPropagation();
|
|
20246
|
-
});
|
|
20263
|
+
}
|
|
20247
20264
|
entryG.append("circle").attr("cx", entryX + LG_DOT_R).attr("cy", LG_HEIGHT / 2).attr("r", LG_DOT_R).attr("fill", entry.color);
|
|
20248
20265
|
const textX = entryX + LG_DOT_R * 2 + LG_ENTRY_DOT_GAP;
|
|
20249
20266
|
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 +20296,8 @@ function renderTimeline(container, parsed, palette, isDark, onClickItem, exportD
|
|
|
20279
20296
|
const groupBg = isDark ? mix(palette.surface, palette.bg, 50) : mix(palette.surface, palette.bg, 30);
|
|
20280
20297
|
const legendGroups = parsed.timelineTagGroups.map((g) => {
|
|
20281
20298
|
const pillW = g.name.length * LG_PILL_FONT_W + LG_PILL_PAD;
|
|
20282
|
-
|
|
20299
|
+
const iconSpace = viewMode ? 8 : LG_ICON_W + 4;
|
|
20300
|
+
let entryX = LG_CAPSULE_PAD + pillW + iconSpace;
|
|
20283
20301
|
for (const entry of g.entries) {
|
|
20284
20302
|
const textX = entryX + LG_DOT_R * 2 + LG_ENTRY_DOT_GAP;
|
|
20285
20303
|
entryX = textX + entry.value.length * LG_ENTRY_FONT_W + LG_ENTRY_TRAIL;
|