forked from carbon-design-system/carbon-charts
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request carbon-design-system#639 from sophiiae/selectedGroups
* Add selectedGroups option * Bind selectedGroups with legend and dataGroups * improvement: move selectedGroup under data option re carbon-design-system#610 * refactor: update selectedGroup position * improvement: grab options from getOptions * improvement: fix naming and update comments * improvement: simplify the code * improvement: remove updateSelectedGroups * fix: remove updateSelectedGroups from legend * test: add unit test for setting up selectedGroups * test: modify unit test * test: renaming * test: revise unit test * test: update test description * style: revise the comment for selectedGroup * test: update test * test: simplify the test code * style: format the code * test: add more tests * test: remove tests for events * test: remove async function * fix: fix check mark position issue and add demos * fix: fix multiple check marks bug * fix: fix chart shrinks between legend click for selected groups * fix: fix legend height change with first legend click * fix: fix demo broken * refactor: renaming * refactor: get legend height * remove semicolon Co-authored-by: Eliad Moosavi <[email protected]> * fix: fix data domain * refactor: rename the demo * fix: fix angular and react height issue Co-authored-by: Fei <[email protected]> Co-authored-by: Eliad Moosavi <[email protected]>
- Loading branch information
1 parent
cd1fb9e
commit e10c1f2
Showing
10 changed files
with
225 additions
and
15 deletions.
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
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
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,56 @@ | ||
import { TestEnvironment } from "./tests/index"; | ||
|
||
// import the settings for the css prefixes | ||
import settings from "carbon-components/es/globals/js/settings"; | ||
|
||
import { options } from "./configuration"; | ||
import { Events } from "./interfaces"; | ||
|
||
import { select } from "d3-selection"; | ||
|
||
describe("selectedGroups option", () => { | ||
beforeEach(function () { | ||
const testEnvironment = new TestEnvironment(); | ||
testEnvironment.render(); | ||
|
||
this.chart = testEnvironment.getChartReference(); | ||
this.testEnvironment = testEnvironment; | ||
}); | ||
|
||
describe("selected legend labels", () => { | ||
it("should match the selected groups provided in options", function (done) { | ||
const sampleSelectedGroups = ["Dataset 1", "Dataset 3"]; | ||
|
||
const chartEventsService = this.chart.services.events; | ||
|
||
const renderCb = () => { | ||
// Remove render event listener | ||
chartEventsService.removeEventListener( | ||
Events.Chart.RENDER_FINISHED, | ||
renderCb | ||
); | ||
|
||
const selectedLegendLabels = select( | ||
`g.${settings.prefix}--${options.chart.style.prefix}--legend` | ||
) | ||
.selectAll("g.legend-item.active > text") | ||
.nodes() | ||
.map((item) => item["innerHTML"]); | ||
|
||
expect(selectedLegendLabels).toEqual(sampleSelectedGroups); | ||
|
||
done(); | ||
}; | ||
|
||
// Add event listener for when chart render is finished | ||
chartEventsService.addEventListener( | ||
Events.Chart.RENDER_FINISHED, | ||
renderCb | ||
); | ||
}); | ||
}); | ||
|
||
afterEach(function () { | ||
this.testEnvironment.destroy(); | ||
}); | ||
}); |
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