-
Notifications
You must be signed in to change notification settings - Fork 360
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
Replace dependence plot with highchart lib #1208
Merged
Merged
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
a898e77
temp
8c82506
test
3d03754
Merge branch 'main' of https://github.com/microsoft/responsible-ai-wi…
e8e24fa
Merge branch 'main' of https://github.com/microsoft/responsible-ai-wi…
267385a
temp
654c8d4
refactor
d75a4e5
tooltip
2870546
cache
d93e945
tooltip template
e25cf74
Merge branch 'main' into zhb/FeatureImportance
zhb000 415c785
remove dup
22b8589
e2e
efc9141
Merge branch 'main' of https://github.com/microsoft/responsible-ai-wi…
f00db78
Merge branch 'main' of https://github.com/microsoft/responsible-ai-to…
b93981a
test
48330a9
test
83068a4
e2e
3283fe0
test
6e03b98
Merge branch 'main' into zhb/FeatureImportance
zhb000 d1bb359
remove animation
72420ad
test
7b01f8f
Merge branch 'main' of https://github.com/microsoft/responsible-ai-to…
78e3dff
fix
d19e40b
Merge branch 'main' into zhb/FeatureImportance
zhb000 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
import { Chart, IChartElement } from "./Chart"; | ||
|
||
// const dReg = /^M([\d.]+),0A(\1),(\1) 0 1,1 0,-(\1)A(\1),(\1) 0 0,1 (\1),0Z$/; | ||
// const transformReg = /^translate\(([\d.]+),([\d.]+)\)$/; | ||
|
||
export interface IHighScatter extends IChartElement { | ||
readonly radius: number; | ||
} | ||
export class ScatterHighchart extends Chart<IHighScatter> { | ||
public get Elements(): any[] { | ||
return this.getHighChartHtmlElements("path"); | ||
} | ||
|
||
public sortByH(): IHighScatter[] { | ||
return this.Elements.sort((a, b) => a.top - b.top); | ||
} | ||
public clickNthPoint(idx: number): void { | ||
const offset = this.getNthPointOffset(idx); | ||
if (!offset) { | ||
return; | ||
} | ||
cy.get(`${this.container} .nsewdrag.drag`).trigger("mousedown", { | ||
clientX: offset.left, | ||
clientY: offset.top, | ||
eventConstructor: "MouseEvent", | ||
force: true | ||
}); | ||
cy.document().then((doc) => { | ||
const event = new MouseEvent("mouseup", { | ||
bubbles: true, | ||
clientX: offset.left, | ||
clientY: offset.top | ||
}); | ||
doc.dispatchEvent(event); | ||
}); | ||
} | ||
|
||
private getNthPointOffset(idx: number): JQuery.Coordinates | undefined { | ||
return cy.$$(`.trace.scatter:eq(0) .points path:eq(${idx})`).offset(); | ||
} | ||
|
||
// private readonly getCoordinate = ( | ||
// element: HTMLElement, | ||
// idx: number | ||
// ): IHighScatter => { | ||
// const d = element.getAttribute("d"); | ||
// if (!d) { | ||
// throw new Error( | ||
// `${idx}th path element in svg does not have "d" attribute` | ||
// ); | ||
// } | ||
// const exec = dReg.exec(d); | ||
// if (!exec) { | ||
// throw new Error( | ||
// `${idx}th path element in svg have invalid "d" attribute` | ||
// ); | ||
// } | ||
// const [, ...strCords] = exec; | ||
// const [radius] = strCords.map((s) => Number(s)); | ||
// const transform = element.getAttribute("transform"); | ||
// if (!transform) { | ||
// throw new Error( | ||
// `${idx}th path element in svg does not have "transform" attribute` | ||
// ); | ||
// } | ||
// const transformExec = transformReg.exec(transform); | ||
// if (!transformExec) { | ||
// throw new Error( | ||
// `${idx}th path element in svg have invalid "transform" attribute ${transform}` | ||
// ); | ||
// } | ||
// const [, ...strTransforms] = transformExec; | ||
// const [x, y] = strTransforms.map((s) => Number(s)); | ||
// return { | ||
// bottom: y + radius, | ||
// left: x - radius, | ||
// radius, | ||
// right: x + radius, | ||
// top: y - radius | ||
// }; | ||
// }; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
import { Chart, IChartElement } from "./Chart"; | ||
|
||
// const dReg = /^M([\d.]+),0A(\1),(\1) 0 1,1 0,-(\1)A(\1),(\1) 0 0,1 (\1),0Z$/; | ||
// const transformReg = /^translate\(([\d.]+),([\d.]+)\)$/; | ||
|
||
export interface IHighScatter extends IChartElement { | ||
readonly radius: number; | ||
} | ||
export class ScatterHighchart extends Chart<IHighScatter> { | ||
public get Elements(): any[] { | ||
return this.getHighChartHtmlElements("path"); | ||
} | ||
|
||
public sortByH(): IHighScatter[] { | ||
return this.Elements.sort((a, b) => a.top - b.top); | ||
} | ||
public clickNthPoint(idx: number): void { | ||
const offset = this.getNthPointOffset(idx); | ||
if (!offset) { | ||
return; | ||
} | ||
cy.get(`${this.container} .nsewdrag.drag`).trigger("mousedown", { | ||
clientX: offset.left, | ||
clientY: offset.top, | ||
eventConstructor: "MouseEvent", | ||
force: true | ||
}); | ||
cy.document().then((doc) => { | ||
const event = new MouseEvent("mouseup", { | ||
bubbles: true, | ||
clientX: offset.left, | ||
clientY: offset.top | ||
}); | ||
doc.dispatchEvent(event); | ||
}); | ||
} | ||
|
||
private getNthPointOffset(idx: number): JQuery.Coordinates | undefined { | ||
return cy.$$(`.trace.scatter:eq(0) .points path:eq(${idx})`).offset(); | ||
} | ||
|
||
// private readonly getCoordinate = ( | ||
// element: HTMLElement, | ||
// idx: number | ||
// ): IHighScatter => { | ||
// const d = element.getAttribute("d"); | ||
// if (!d) { | ||
// throw new Error( | ||
// `${idx}th path element in svg does not have "d" attribute` | ||
// ); | ||
// } | ||
// const exec = dReg.exec(d); | ||
// if (!exec) { | ||
// throw new Error( | ||
// `${idx}th path element in svg have invalid "d" attribute` | ||
// ); | ||
// } | ||
// const [, ...strCords] = exec; | ||
// const [radius] = strCords.map((s) => Number(s)); | ||
// const transform = element.getAttribute("transform"); | ||
// if (!transform) { | ||
// throw new Error( | ||
// `${idx}th path element in svg does not have "transform" attribute` | ||
// ); | ||
// } | ||
// const transformExec = transformReg.exec(transform); | ||
// if (!transformExec) { | ||
// throw new Error( | ||
// `${idx}th path element in svg have invalid "transform" attribute ${transform}` | ||
// ); | ||
// } | ||
// const [, ...strTransforms] = transformExec; | ||
// const [x, y] = strTransforms.map((s) => Number(s)); | ||
// return { | ||
// bottom: y + radius, | ||
// left: x - radius, | ||
// radius, | ||
// right: x + radius, | ||
// top: y - radius | ||
// }; | ||
// }; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
import { ITheme } from "@fluentui/react"; | ||
|
||
import { IHighchartsConfig } from "../Highchart/HighchartTypes"; | ||
|
||
export interface IDependenceData { | ||
x: number; | ||
y: number; | ||
customData: any[]; | ||
} | ||
|
||
export function getDependencyChartOptions( | ||
data: IDependenceData[], | ||
xLabels: string[] | undefined, | ||
theme?: ITheme | ||
): IHighchartsConfig { | ||
const colorTheme = { | ||
axisColor: theme?.palette.neutralPrimary, | ||
axisGridColor: theme?.palette.neutralLight, | ||
backgroundColor: theme?.palette.white, | ||
fontColor: theme?.semanticColors.bodyText | ||
}; | ||
return { | ||
chart: { | ||
animation: false, | ||
backgroundColor: colorTheme.backgroundColor, | ||
type: "scatter", | ||
zoomType: "xy" | ||
}, | ||
legend: {}, | ||
plotOptions: { | ||
scatter: { | ||
marker: { | ||
radius: 2, | ||
states: { | ||
hover: { | ||
enabled: true, | ||
lineColor: colorTheme.axisColor | ||
} | ||
} | ||
}, | ||
tooltip: { | ||
headerFormat: "", | ||
pointFormat: `{point.customData.template}` | ||
} | ||
} | ||
}, | ||
series: [ | ||
{ | ||
color: colorTheme.fontColor, | ||
data, | ||
name: "", | ||
type: "scatter" | ||
} | ||
], | ||
subtitle: {}, | ||
title: { text: "" }, | ||
xAxis: { | ||
categories: xLabels, | ||
labels: { | ||
style: { | ||
color: colorTheme.fontColor | ||
} | ||
}, | ||
title: { | ||
text: "" | ||
} | ||
}, | ||
yAxis: { | ||
labels: { | ||
style: { | ||
color: colorTheme.fontColor | ||
} | ||
}, | ||
title: { | ||
text: "" | ||
} | ||
} | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe refactor out the common xAxis and yAxis properties to a method?