Skip to content

Commit

Permalink
upgrade plotly to latest version 2.27.1 (microsoft#2484)
Browse files Browse the repository at this point in the history
  • Loading branch information
imatiach-msft authored Jan 10, 2024
1 parent c2a9352 commit 49906bb
Show file tree
Hide file tree
Showing 35 changed files with 14,989 additions and 16,681 deletions.
5 changes: 4 additions & 1 deletion apps/dashboard/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,8 @@ module.exports = {
"babel-jest",
{ configFile: "./babel-jest.config.json", cwd: __dirname }
]
}
},
transformIgnorePatterns: [
"/node_modules/(?!d3|d3-array|internmap|delaunator|robust-predicates)"
]
};
5 changes: 4 additions & 1 deletion apps/widget/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,8 @@ module.exports = {
"babel-jest",
{ configFile: "./babel-jest.config.json", cwd: __dirname }
]
}
},
transformIgnorePatterns: [
"/node_modules/(?!d3|d3-array|internmap|delaunator|robust-predicates)"
]
};
3 changes: 3 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,8 @@ module.exports = {
"<rootDir>/libs/error-analysis",
"<rootDir>/libs/forecasting",
"<rootDir>/apps/widget"
],
transformIgnorePatterns: [
"/node_modules/(?!d3|d3-array|internmap|delaunator|robust-predicates)"
]
};
5 changes: 4 additions & 1 deletion libs/causality/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,8 @@ module.exports = {
"babel-jest",
{ configFile: "./babel-jest.config.json", cwd: __dirname }
]
}
},
transformIgnorePatterns: [
"/node_modules/(?!d3|d3-array|internmap|delaunator|robust-predicates)"
]
};
5 changes: 4 additions & 1 deletion libs/core-ui/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,8 @@ module.exports = {
"babel-jest",
{ configFile: "./babel-jest.config.json", cwd: __dirname }
]
}
},
transformIgnorePatterns: [
"/node_modules/(?!d3|d3-array|internmap|delaunator|robust-predicates)"
]
};
5 changes: 4 additions & 1 deletion libs/counterfactuals/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,8 @@ module.exports = {
"babel-jest",
{ configFile: "./babel-jest.config.json", cwd: __dirname }
]
}
},
transformIgnorePatterns: [
"/node_modules/(?!d3|d3-array|internmap|delaunator|robust-predicates)"
]
};
5 changes: 4 additions & 1 deletion libs/dataset-explorer/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,8 @@ module.exports = {
"babel-jest",
{ configFile: "./babel-jest.config.json", cwd: __dirname }
]
}
},
transformIgnorePatterns: [
"/node_modules/(?!d3|d3-array|internmap|delaunator|robust-predicates)"
]
};
5 changes: 4 additions & 1 deletion libs/e2e/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,8 @@ module.exports = {
preset: "../../jest.preset.js",
transform: {
"^.+\\.[tj]sx?$": "babel-jest"
}
},
transformIgnorePatterns: [
"/node_modules/(?!d3|d3-array|internmap|delaunator|robust-predicates)"
]
};
5 changes: 4 additions & 1 deletion libs/error-analysis/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,8 @@ module.exports = {
"babel-jest",
{ configFile: "./babel-jest.config.json", cwd: __dirname }
]
}
},
transformIgnorePatterns: [
"/node_modules/(?!d3|d3-array|internmap|delaunator|robust-predicates)"
]
};
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@

import { getTheme } from "@fluentui/react";
import { getRandomId, SVGToolTip } from "@responsible-ai/core-ui";
import { HierarchyPointNode } from "d3-hierarchy";
import React from "react";

import { ColorPalette } from "../../ColorPalette";
import { IHierarchyPointNode as HierarchyPointNode } from "../../Interfaces/IHierarchyPointNode";
import { FilterTooltip } from "../FilterTooltip/FilterTooltip";

import { treeViewRendererStyles } from "./TreeViewRenderer.styles";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,7 @@ import {
import { localization } from "@responsible-ai/localization";
import { Property } from "csstype";
import { max as d3max } from "d3-array";
import {
stratify as d3stratify,
tree as d3tree,
HierarchyPointNode
} from "d3-hierarchy";
import { stratify as d3stratify, tree as d3tree } from "d3-hierarchy";
import { interpolateHcl as d3interpolateHcl } from "d3-interpolate";
import { scaleLinear as d3scaleLinear } from "d3-scale";
import { select } from "d3-selection";
Expand All @@ -41,6 +37,7 @@ import React from "react";

import { ColorPalette } from "../../ColorPalette";
import { FilterProps } from "../../FilterProps";
import { IHierarchyPointNode as HierarchyPointNode } from "../../Interfaces/IHierarchyPointNode";
import { TreeLegend } from "../TreeLegend/TreeLegend";

import { TreeViewNode } from "./TreeViewNode";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import {
Metrics
} from "@responsible-ai/core-ui";
import { Property } from "csstype";
import { HierarchyPointNode } from "d3-hierarchy";

import { FilterProps } from "../../FilterProps";
import { IHierarchyPointNode as HierarchyPointNode } from "../../Interfaces/IHierarchyPointNode";

export interface IErrorColorStyle {
fill: string | undefined;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@

import { Metrics } from "@responsible-ai/core-ui";
import { localization } from "@responsible-ai/localization";
import { HierarchyPointNode } from "d3-hierarchy";

import { FilterProps } from "../../FilterProps";
import { IHierarchyPointNode as HierarchyPointNode } from "../../Interfaces/IHierarchyPointNode";
import { MetricLocalizationType, MetricUtils } from "../../MetricUtils";

import { ITreeNode } from "./TreeViewState";
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

import * as d3hierarchy from "d3-hierarchy";

// This is to get around a typescript import issue with d3-hierarchy
export type IHierarchyPointNode<TDatum> =
d3hierarchy.HierarchyPointNode<TDatum>;
5 changes: 4 additions & 1 deletion libs/fairness/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,8 @@ module.exports = {
"babel-jest",
{ configFile: "./babel-jest.config.json", cwd: __dirname }
]
}
},
transformIgnorePatterns: [
"/node_modules/(?!d3|d3-array|internmap|delaunator|robust-predicates)"
]
};
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ export function getPlotlyProps(
y
);

series.customdata.push({
(series.customdata as Datum[]).push({
modelId,
x: x?.toFixed(digitsOfPrecision),
xBounds,
Expand Down
2 changes: 1 addition & 1 deletion libs/fairness/src/lib/Controls/OutcomePlot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ export class OutcomePlot extends React.PureComponent<IOutcomePlotProps> {
).toFixed(digitsOfPrecision)}%]`
: "";

barPlotlyProps.data[0].customdata.push({
(barPlotlyProps.data[0].customdata as Datum[]).push({
outcomeMetric: outcomeMetric.title,
x: x !== undefined ? (100 * x).toFixed(digitsOfPrecision) : undefined,
xBounds,
Expand Down
2 changes: 1 addition & 1 deletion libs/fairness/src/lib/Controls/PerformancePlotHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export function buildCustomTooltips(
: "";
const customdata = barPlotlyProps?.data?.[j]?.customdata;
if (customdata && _.isArray(customdata)) {
customdata.push({
(customdata as Datum[]).push({
outcomeMetric,
x:
x !== undefined
Expand Down
5 changes: 4 additions & 1 deletion libs/forecasting/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,8 @@ module.exports = {
"babel-jest",
{ configFile: "./babel-jest.config.json", cwd: __dirname }
]
}
},
transformIgnorePatterns: [
"/node_modules/(?!d3|d3-array|internmap|delaunator|robust-predicates)"
]
};
5 changes: 4 additions & 1 deletion libs/interpret-text/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,8 @@ module.exports = {
"babel-jest",
{ configFile: "./babel-jest.config.json", cwd: __dirname }
]
}
},
transformIgnorePatterns: [
"/node_modules/(?!d3|d3-array|internmap|delaunator|robust-predicates)"
]
};
5 changes: 4 additions & 1 deletion libs/interpret-vision/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,8 @@ module.exports = {
"babel-jest",
{ configFile: "./babel-jest.config.json", cwd: __dirname }
]
}
},
transformIgnorePatterns: [
"/node_modules/(?!d3|d3-array|internmap|delaunator|robust-predicates)"
]
};
5 changes: 4 additions & 1 deletion libs/interpret/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,8 @@ module.exports = {
"babel-jest",
{ configFile: "./babel-jest.config.json", cwd: __dirname }
]
}
},
transformIgnorePatterns: [
"/node_modules/(?!d3|d3-array|internmap|delaunator|robust-predicates)"
]
};
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import {
} from "@responsible-ai/mlchartlib";
import _ from "lodash";
import memoize from "memoize-one";
import Plotly from "plotly.js";
import Plotly, { PlotMarker } from "plotly.js";
import React from "react";

import { LoadingSpinner } from "../../SharedComponents/LoadingSpinner";
Expand Down Expand Up @@ -253,7 +253,7 @@ export class Beehive extends React.PureComponent<
selectedOption.text
);
if (selectedOption.data.isNormalized && plotlyProps.data[0].marker) {
plotlyProps.data[0].marker.colorscale = [
(plotlyProps.data[0].marker as Partial<PlotMarker>).colorscale = [
[0, "rgba(0,0,255,0.5)"],
[1, "rgba(255,0,0,0.5)"]
];
Expand Down
4 changes: 2 additions & 2 deletions libs/interpret/src/lib/MLIDashboard/Controls/ICEPlot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ import { localization } from "@responsible-ai/localization";
import {
AccessibleChart,
ICategoricalRange,
IData,
INumericRange,
IPlotlyProperty,
PlotlyMode,
RangeTypes
} from "@responsible-ai/mlchartlib";
import _, { toNumber } from "lodash";
import memoize from "memoize-one";
import { Data } from "plotly.js";
import React from "react";

import { HelpMessageDict } from "../Interfaces/IStringsParam";
Expand Down Expand Up @@ -87,7 +87,7 @@ export class ICEPlot extends React.Component<IIcePlotProps, IIcePlotState> {
const transposedY: number[][] = Array.isArray(yData[0])
? ModelExplanationUtils.transpose2DArray(yData as number[][])
: [yData as number[]];
const data: Data[] = transposedY.map((singleClassValue, classIndex) => {
const data: IData[] = transposedY.map((singleClassValue, classIndex) => {
return {
hoverinfo: "text",
mode:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@ import {
ModelTypes
} from "@responsible-ai/core-ui";
import { localization } from "@responsible-ai/localization";
import { RangeTypes } from "@responsible-ai/mlchartlib";
import { RangeTypes, IData } from "@responsible-ai/mlchartlib";
import { map } from "lodash";
import { Data } from "plotly.js";

import { buildYAxis } from "./buildYAxis";
import { mergeXYData } from "./mergeXYData";
Expand Down Expand Up @@ -39,7 +38,7 @@ export function getIceChartOption(
) {
return undefined;
}
const data: Data[] = map<number[] | number[][]>(
const data: IData[] = map<number[] | number[][]>(
yData,
(singleRow: number[] | number[][], rowIndex: number) => {
const transposedY: number[][] = isTwoDimArray(singleRow)
Expand Down
5 changes: 4 additions & 1 deletion libs/localization/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,8 @@ module.exports = {
"babel-jest",
{ configFile: "./babel-jest.config.json", cwd: __dirname }
]
}
},
transformIgnorePatterns: [
"/node_modules/(?!d3|d3-array|internmap|delaunator|robust-predicates)"
]
};
5 changes: 4 additions & 1 deletion libs/mlchartlib/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,8 @@ module.exports = {
"babel-jest",
{ configFile: "./babel-jest.config.json", cwd: __dirname }
]
}
},
transformIgnorePatterns: [
"/node_modules/(?!d3|d3-array|internmap|delaunator|robust-predicates)"
]
};
3 changes: 2 additions & 1 deletion libs/mlchartlib/src/lib/components/AccessibleChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { v4 } from "uuid";

import { accessibleChartStyles } from "./AccessibleChart.styles";
import { formatValue } from "./DisplayFormatters";
import { IData } from "./IData";
import { IPlotlyProperty } from "./IPlotlyProperty";
import { PlotlyThemes, IPlotlyTheme } from "./PlotlyThemes";

Expand Down Expand Up @@ -97,7 +98,7 @@ export class AccessibleChart extends React.Component<IAccessibleChartProps> {
);
}

private createTableWithPlotlyData(data: Plotly.Data[]): React.ReactNode {
private createTableWithPlotlyData(data: IData[]): React.ReactNode {
return (
<table className={accessibleChartStyles.plotlyTable}>
<tbody>
Expand Down
15 changes: 6 additions & 9 deletions libs/mlchartlib/src/lib/components/ChartBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,7 @@ interface IRow {
size: any;
}
export class ChartBuilder {
public static buildPlotlySeries<T>(
datum: IData,
rows: T[]
): Array<Partial<Data>> {
public static buildPlotlySeries<T>(datum: IData, rows: T[]): IData[] {
const groupingDictionary: { [key: string]: Partial<Data> } = {};
let defaultSeries: Partial<Data> | undefined;
const datumLevelPaths: string = datum.datapointLevelAccessors
Expand All @@ -43,7 +40,7 @@ export class ChartBuilder {
// the preferred solution of size ref
const maxBubbleValue = 10;
projectedRows.forEach((row) => {
let series: Partial<Data>;
let series: IData;

// Handle mutiple group by in the future
if (datum.groupBy && datum.groupBy.length > 0) {
Expand All @@ -52,20 +49,20 @@ export class ChartBuilder {
if (defaultSeries === undefined) {
defaultSeries = ChartBuilder.buildDefaultSeries(datum);
}
series = defaultSeries;
series = defaultSeries as IData;
} else {
if (groupingDictionary[key] === undefined) {
const temp = ChartBuilder.buildDefaultSeries(datum);
temp.name = key;
groupingDictionary[key] = temp;
}
series = groupingDictionary[key];
series = groupingDictionary[key] as IData;
}
} else {
if (defaultSeries === undefined) {
defaultSeries = ChartBuilder.buildDefaultSeries(datum);
}
series = defaultSeries;
series = defaultSeries as IData;
}

// Due to logging supporting heterogeneous metric types, a metric can be a scalar on one run and a vector on another
Expand Down Expand Up @@ -146,7 +143,7 @@ export class ChartBuilder {
Object.keys(groupingDictionary).forEach((key) => {
result.push(groupingDictionary[key]);
});
return result;
return result as IData[];
}

private static getHasVectors(row: IRow): {
Expand Down
Loading

0 comments on commit 49906bb

Please sign in to comment.