Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated smith chart and 1h Gantt #133

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2,186 changes: 537 additions & 1,649 deletions prototypes/one-hour-gantt-chart/package-lock.json

Large diffs are not rendered by default.

6 changes: 2 additions & 4 deletions prototypes/one-hour-gantt-chart/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "spider-chart-mod",
"name": "one-hour-gantt-chart-mod",
"version": "1.0.0",
"description": "",
"main": "index.js",
Expand All @@ -14,16 +14,14 @@
"license": "ISC",
"devDependencies": {
"@spotfire/mods-dev-server": "^1.0.1",
"@types/d3": "^5.16.4",
"@types/jest": "27.4.1",
"copy-webpack-plugin": "10.2.4",
"d3": "^5.14.2",
"gantt": "3.1.1",
"jest": "27.5.1",
"ts-jest": "27.1.4",
"ts-loader": "9.2.8",
"typescript": "4.6.3",
"webpack": "5.72.0",
"webpack": "^5.88.2",
"webpack-cli": "4.9.2"
}
}
13 changes: 0 additions & 13 deletions prototypes/one-hour-gantt-chart/src/helper.ts

This file was deleted.

100 changes: 7 additions & 93 deletions prototypes/one-hour-gantt-chart/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import { Data, Options, render } from "./render";
import { createLabelPopout } from "./popout";
import { buildColorSeries, Point } from "./series";
import { renderGantt } from "./gantt-chart";
import { AxisPart, DataView, DataViewHierarchyNode, Mod, ModProperty } from "spotfire-api";
import { DataView } from "spotfire-api";
var events = require("events");

const Spotfire = window.Spotfire;
Expand Down Expand Up @@ -67,11 +64,11 @@ Spotfire.initialize(async (mod) => {
links: linksHierarchy?.isEmpty
? []
: leaf.rows().map((r) => {
return {
target: r.categorical("Link").value()[0].key,
type: "FS",
};
}),
return {
target: r.categorical("Link").value()[0].key,
type: "FS",
};
}),
};
}

Expand Down Expand Up @@ -149,87 +146,4 @@ export function generalErrorHandler<T extends (dataView: Spotfire.DataView, ...a
}
} as T;
};
}

/**
* Construct a data format suitable for consumption in d3.
* @param mod The Mod API object
* @param dataView The mod's DataView
*/
async function buildData(mod: Mod, dataView: DataView): Promise<Data> {
const allRows = await dataView.allRows();

const allYValues: Array<number> = allRows!.map((row) => row.continuous<number>("Y").value() || 0);
const maxValue = Math.max(...allYValues);
const minValue = Math.min(0, ...allYValues);

const xHierarchy = await dataView.hierarchy("X");

const colorLeaves = (await (await dataView.hierarchy("Color"))!.root())!.leaves();
const xHierarchyLeaves = (await xHierarchy!.root())!.leaves();

const xAxisData = xHierarchyLeaves.map((leaf) => leaf.formattedPath());

const xAxisMeta = await mod.visualization.axis("X");
const yAxisMeta = await mod.visualization.axis("Y");
const colorAxisMeta = await mod.visualization.axis("Color");

return {
clearMarking: dataView.clearMarking,
yDomain: { min: minValue, max: maxValue },
xScale: xAxisData,
series: buildColorSeries(
colorLeaves,
xHierarchyLeaves,
!(xHierarchy?.isEmpty ?? true),
createPointTooltip,
minValue
),
};

function createPointTooltip(point: Point) {
const separator = "\n";
let colorValues = getFormattedValues(colorLeaves[point.index]);
let xValues = getFormattedValues(xHierarchyLeaves[point.xIndex]);
let yDisplayName = yAxisMeta.parts[0].displayName;

if (yAxisMeta.parts.length > 1) {
// Find the corresponding display name for the y axis value.
let colorLevelForColumnNames = colorAxisMeta.parts.map((p) => p.expression).indexOf("[Axis.Default.Names]");
let xLevelForColumnNames = xAxisMeta.parts.map((p) => p.expression).indexOf("[Axis.Default.Names]");
if (colorLevelForColumnNames >= 0) {
yDisplayName = colorValues[colorLevelForColumnNames];
}

if (xLevelForColumnNames >= 0) {
yDisplayName = xValues[xLevelForColumnNames];
}
}

return [
createAxisTooltip(xAxisMeta.parts, xValues, separator) ||
xAxisMeta.parts[0].displayName + ": " + xHierarchyLeaves[point.xIndex].formattedPath(),
yDisplayName + ": " + point.Y_Formatted,
colorAxisMeta.parts.length > 0
? createAxisTooltip(colorAxisMeta.parts, colorValues, separator) ||
colorAxisMeta.parts[0].displayName + ": " + colorLeaves[point.index].formattedPath()
: "",
].join(separator);
}

function getFormattedValues(node: DataViewHierarchyNode) {
let values: string[] = [];
while (node.parent) {
values.push(node.formattedValue());
node = node.parent;
}

return values.reverse();
}

function createAxisTooltip(axisParts: AxisPart[], formattedValues: string[], separator: string) {
return axisParts.length == formattedValues.length
? formattedValues.map((v, i) => axisParts[i].displayName + ": " + v).join(separator)
: null;
}
}
}
90 changes: 0 additions & 90 deletions prototypes/one-hour-gantt-chart/src/popout.ts

This file was deleted.

Loading