|
1 | | -// Copyright (c) Microsoft Corporation. |
2 | | -// Licensed under the MIT License. |
3 | | - |
4 | | -import { ScatterChart } from "../../../util/ScatterChart"; |
5 | | -import { IInterpretData } from "../IInterpretData"; |
6 | | - |
7 | | -import { describeSubBarChart } from "./describeSubBarChart"; |
8 | | -import { describeSubLineChart } from "./describeSubLineChart"; |
9 | | - |
10 | | -export function describeDataPointChart(dataShape: IInterpretData): void { |
11 | | - describe("Individual datapoints chart", () => { |
12 | | - const props = { |
13 | | - chart: undefined as unknown as ScatterChart, |
14 | | - dataShape |
15 | | - }; |
16 | | - beforeEach(() => { |
17 | | - props.chart = new ScatterChart("#IndividualFeatureImportanceChart"); |
18 | | - }); |
19 | | - it("should render right number of points", () => { |
20 | | - expect(props.chart.Elements.length).equals(dataShape.datapoint); |
21 | | - }); |
22 | | - |
23 | | - describe("Scatter chart clickable", () => { |
24 | | - it("should select none by default", () => { |
25 | | - cy.get( |
26 | | - '#IndividualFeatureContainer div[class^="legendAndText"] div[class^="clickTarget"]' |
27 | | - ).should("not.exist"); |
28 | | - }); |
29 | | - it("should show message on sub chart", () => { |
30 | | - const message = |
31 | | - !dataShape.noLocalImportance && !dataShape.noFeatureImportance |
32 | | - ? "Select a datapoint in the table above to view its local feature importances" |
33 | | - : "Provide local feature importances to see how each feature impacts individual predictions."; |
34 | | - cy.get("#subPlotContainer").should("contain.text", message); |
35 | | - }); |
36 | | - it("should select the first point", () => { |
37 | | - props.chart.clickNthPoint(0); |
38 | | - cy.get( |
39 | | - '#IndividualFeatureContainer div[class^="legendAndText"] div[class^="clickTarget"]' |
40 | | - ).should("contain.text", "Row"); |
41 | | - cy.get("#noPointSelectedInfo").should("not.exist"); |
42 | | - props.chart.clickNthPoint(0); |
43 | | - }); |
44 | | - }); |
45 | | - |
46 | | - if (!dataShape.noLocalImportance && !dataShape.noFeatureImportance) { |
47 | | - describeSubBarChart(dataShape); |
48 | | - } |
49 | | - if (!dataShape.noPredict) { |
50 | | - describeSubLineChart(dataShape); |
51 | | - } |
52 | | - }); |
53 | | -} |
| 1 | +// Copyright (c) Microsoft Corporation. |
| 2 | +// Licensed under the MIT License. |
| 3 | + |
| 4 | +import { ScatterChart } from "../../../util/ScatterChart"; |
| 5 | +import { IInterpretData } from "../IInterpretData"; |
| 6 | + |
| 7 | +import { describeSubBarChart } from "./describeSubBarChart"; |
| 8 | +import { describeSubLineChart } from "./describeSubLineChart"; |
| 9 | + |
| 10 | +export function describeDataPointChart(dataShape: IInterpretData): void { |
| 11 | + describe("Individual datapoints chart", () => { |
| 12 | + const props = { |
| 13 | + chart: undefined as unknown as ScatterChart, |
| 14 | + dataShape |
| 15 | + }; |
| 16 | + beforeEach(() => { |
| 17 | + props.chart = new ScatterChart("#IndividualFeatureImportanceChart"); |
| 18 | + }); |
| 19 | + it("should render right number of points", () => { |
| 20 | + // Wait for the chart to be fully rendered by checking for the scatter plot points |
| 21 | + // Using the same selector pattern as ScatterChart.Elements getter |
| 22 | + cy.get("#IndividualFeatureImportanceChart .trace.scatter .points path", { |
| 23 | + timeout: 10000 |
| 24 | + }).should("have.length", dataShape.datapoint); |
| 25 | + }); |
| 26 | + |
| 27 | + describe("Scatter chart clickable", () => { |
| 28 | + it("should select none by default", () => { |
| 29 | + cy.get( |
| 30 | + '#IndividualFeatureContainer div[class^="legendAndText"] div[class^="clickTarget"]' |
| 31 | + ).should("not.exist"); |
| 32 | + }); |
| 33 | + it("should show message on sub chart", () => { |
| 34 | + const message = |
| 35 | + !dataShape.noLocalImportance && !dataShape.noFeatureImportance |
| 36 | + ? "Select a datapoint in the table above to view its local feature importances" |
| 37 | + : "Provide local feature importances to see how each feature impacts individual predictions."; |
| 38 | + cy.get("#subPlotContainer").should("contain.text", message); |
| 39 | + }); |
| 40 | + it("should select the first point", () => { |
| 41 | + props.chart.clickNthPoint(0); |
| 42 | + cy.get( |
| 43 | + '#IndividualFeatureContainer div[class^="legendAndText"] div[class^="clickTarget"]' |
| 44 | + ).should("contain.text", "Row"); |
| 45 | + cy.get("#noPointSelectedInfo").should("not.exist"); |
| 46 | + props.chart.clickNthPoint(0); |
| 47 | + }); |
| 48 | + }); |
| 49 | + |
| 50 | + if (!dataShape.noLocalImportance && !dataShape.noFeatureImportance) { |
| 51 | + describeSubBarChart(dataShape); |
| 52 | + } |
| 53 | + if (!dataShape.noPredict) { |
| 54 | + describeSubLineChart(dataShape); |
| 55 | + } |
| 56 | + }); |
| 57 | +} |
0 commit comments