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

Dev/gantt no color #119

Open
wants to merge 4 commits 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
44 changes: 23 additions & 21 deletions catalog/gantt-chart/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,8 @@ Spotfire.initialize(async (mod) => {
(tot, curr) =>
tot +
(curr.continuous("Progress").value() as number) *
((curr.continuous("End").value() as Date).getTime() -
(curr.continuous("Start").value() as Date).getTime() || 1),
((curr.continuous("End").value() as Date).getTime() -
(curr.continuous("Start").value() as Date).getTime() || 1),
0
) /
rows.reduce(
Expand Down Expand Up @@ -204,13 +204,13 @@ Spotfire.initialize(async (mod) => {
start: startDates[0],
end: endDates[0],
isMarked: node.rows().every((r) => r.isMarked()),
color: getColor(node, tasksRootNode, colorAxis.isCategorical)
color: getColor(node, tasksRootNode, !!colorAxis.parts.length, colorAxis.isCategorical)
};
}
}
}

function getColor(node: DataViewHierarchyNode, root: DataViewHierarchyNode, isCategorical: boolean) {
function getColor(node: DataViewHierarchyNode, root: DataViewHierarchyNode, hasColorExpression: boolean, isCategorical: boolean) {
let color = config.defaultBarColor;

const unmarkedRows = node.rows().filter((r) => !r.isMarked());
Expand All @@ -222,21 +222,23 @@ Spotfire.initialize(async (mod) => {
color = node.rows()[0].color().hexCode;
}

if (isCategorical) {
const colorValue = node.rows()[0].categorical("Color").value()[0].key;
const differentElements = node.rows().filter((r) => {
return r.categorical("Color").value()[0].key !== colorValue;
}).length;
if (differentElements > 0) {
color = config.defaultBarColor;
}
} else {
const colorValue = node.rows()[0].continuous("Color").value();
const differentElements = node.rows().filter((r) => {
return r.continuous("Color").value() !== colorValue;
}).length;
if (differentElements > 0) {
color = config.defaultBarColor;
if (hasColorExpression) {
if (isCategorical) {
const colorValue = node.rows()[0].categorical("Color").value()[0].key;
objerke marked this conversation as resolved.
Show resolved Hide resolved
const differentElements = node.rows().filter((r) => {
return r.categorical("Color").value()[0].key !== colorValue;
}).length;
if (differentElements > 0) {
color = config.defaultBarColor;
}
} else {
const colorValue = node.rows()[0].continuous("Color").value();
objerke marked this conversation as resolved.
Show resolved Hide resolved
const differentElements = node.rows().filter((r) => {
return r.continuous("Color").value() !== colorValue;
}).length;
if (differentElements > 0) {
color = config.defaultBarColor;
}
}
}
} else {
Expand Down Expand Up @@ -318,8 +320,8 @@ export function generalErrorHandler<T extends (dataView: Spotfire.DataView, ...a
} catch (e) {
mod.controls.errorOverlay.show(
[e.message].concat(messages.InitialConfigurationHelper) ||
e ||
"☹️ Something went wrong, check developer console",
e ||
"☹️ Something went wrong, check developer console",
"General"
);
if (DEBUG) {
Expand Down
2 changes: 1 addition & 1 deletion catalog/gantt-chart/static/mod-manifest.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"apiVersion": "1.2",
"version": "1.0.1",
"version": "1.1.0",
"name": "Gantt chart",
"id": "ts-gantt-chart",
"icon": "icon.svg",
Expand Down