forked from opensearch-project/OpenSearch-Dashboards
-
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.
[VisBuilder-Next] Pie Chart Integration for VisBuilder (opensearch-pr…
…oject#7752) (opensearch-project#8553) * [VisBuilder-Next] Pie Chart Integration for VisBuilder This PR integrates pie charts into VisBuilder using Vega rendering. Issue Resolve: opensearch-project#7607 --------- (cherry picked from commit 615d7d4) Signed-off-by: Anan Zhuang <[email protected]> Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
- Loading branch information
1 parent
3cbb65d
commit 50a714f
Showing
32 changed files
with
1,084 additions
and
53 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
File renamed without changes.
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
56 changes: 56 additions & 0 deletions
56
src/plugins/vis_builder/public/visualizations/vega/components/mark/mark_slices.test.ts
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 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import { buildSlicesMarkForVega, buildPieMarks, buildArcMarks } from './mark_slices'; | ||
|
||
describe('buildSlicesMarkForVega', () => { | ||
it('should return a group mark with correct properties', () => { | ||
const result = buildSlicesMarkForVega(['level1', 'level2'], true, true); | ||
expect(result.type).toBe('group'); | ||
expect(result.from).toEqual({ data: 'splits' }); | ||
expect(result.encode.enter.width).toEqual({ signal: 'chartWidth' }); | ||
expect(result.title).toBeDefined(); | ||
expect(result.data).toBeDefined(); | ||
expect(result.marks).toBeDefined(); | ||
}); | ||
|
||
it('should handle non-split case correctly', () => { | ||
const result = buildSlicesMarkForVega(['level1'], false, true); | ||
expect(result.from).toBeNull(); | ||
expect(result.encode.enter.width).toEqual({ signal: 'width' }); | ||
expect(result.title).toBeNull(); | ||
}); | ||
}); | ||
|
||
describe('buildPieMarks', () => { | ||
it('should create correct number of marks', () => { | ||
const result = buildPieMarks(['level1', 'level2'], true); | ||
expect(result).toHaveLength(2); | ||
}); | ||
|
||
it('should create correct transformations', () => { | ||
const result = buildPieMarks(['level1'], true); | ||
expect(result[0].transform).toHaveLength(3); | ||
expect(result[0].transform[0].type).toBe('filter'); | ||
expect(result[0].transform[1].type).toBe('aggregate'); | ||
expect(result[0].transform[2].type).toBe('pie'); | ||
}); | ||
}); | ||
|
||
describe('buildArcMarks', () => { | ||
it('should create correct number of arc marks', () => { | ||
const result = buildArcMarks(['level1', 'level2'], false); | ||
expect(result).toHaveLength(2); | ||
expect(result[0].encode.update.tooltip).toBeUndefined(); | ||
}); | ||
|
||
it('should create arc marks with correct properties', () => { | ||
const result = buildArcMarks(['level1'], true); | ||
expect(result[0].type).toBe('arc'); | ||
expect(result[0].encode.enter.fill).toBeDefined(); | ||
expect(result[0].encode.update.startAngle).toBeDefined(); | ||
expect(result[0].encode.update.tooltip).toBeDefined(); | ||
}); | ||
}); |
Oops, something went wrong.