-
Notifications
You must be signed in to change notification settings - Fork 923
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
This PR integrates pie charts into VisBuilder using Vega rendering. Issue Resolve: #7752 Signed-off-by: Anan Zhuang <[email protected]>
- Loading branch information
Showing
28 changed files
with
947 additions
and
48 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
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
55 changes: 55 additions & 0 deletions
55
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,55 @@ | ||
/* | ||
* 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']); | ||
expect(result).toHaveLength(2); | ||
}); | ||
|
||
it('should create arc marks with correct properties', () => { | ||
const result = buildArcMarks(['level1']); | ||
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.