-
Notifications
You must be signed in to change notification settings - Fork 916
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
[VisBuilder] Add Capability to generate dynamic vega #7288
Conversation
❌ Empty Changelog SectionThe Changelog section in your PR description is empty. Please add a valid changelog entry or entries. If you did add a changelog entry, check to make sure that it was not accidentally included inside the comment block in the Changelog section. |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #7288 +/- ##
==========================================
+ Coverage 67.62% 67.69% +0.07%
==========================================
Files 3584 3595 +11
Lines 72205 72404 +199
Branches 11818 11867 +49
==========================================
+ Hits 48826 49014 +188
+ Misses 20391 20385 -6
- Partials 2988 3005 +17
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
❌ Empty Changelog SectionThe Changelog section in your PR description is empty. Please add a valid changelog entry or entries. If you did add a changelog entry, check to make sure that it was not accidentally included inside the comment block in the Changelog section. |
f1017e0
to
1083974
Compare
* update file and functions names * fix type errors * fix area chart Signed-off-by: Anan Zhuang <[email protected]>
3229fac
to
c37996e
Compare
* @param {any} formats - The formatting information for axes. | ||
* @returns {VegaScale[]} The Vega scale configurations. | ||
*/ | ||
export const buildVegaScales = (dimensions: any, formats: any): VegaScale[] => { |
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.
The function doesn't seem to be using formats parameter. This parameter can be cleaned.
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.
Will update. thx.
Signed-off-by: Anan Zhuang <[email protected]>
Signed-off-by: Anan Zhuang <[email protected]>
Signed-off-by: Anan Zhuang <[email protected]>
* @returns {string} The corresponding Vega data type | ||
*/ | ||
export const mapFieldTypeToVegaType = (fieldType) => { | ||
const typeMap = { |
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.
nit: We can use an enum to define the typeMap and add it to the constants file
|
||
// Build the base Vega-Lite specification | ||
const baseSpec: VegaLiteSpec = { | ||
$schema: 'https://vega.github.io/schema/vega-lite/v5.json', |
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.
nit: We can store it as a constant so it would be easier to modify it in future if required.
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.
Will polish in a follow up PR.
$schema: 'https://vega.github.io/schema/vega-lite/v5.json', | ||
data: { values: transformedData }, | ||
mark: buildMarkForVegaLite(vegaType), | ||
encoding: buildVegaLiteEncoding(dimensions, formats), |
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.
nit: We are calling buildVegaLiteEncoding(dimensions, formats)
three times separately in the function , we can store the value in first call and use it across places.
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.
Will polish in a follow up PR.
Signed-off-by: Anan Zhuang <[email protected]>
cbebec5
to
ae9e15b
Compare
Signed-off-by: Anan Zhuang <[email protected]>
91ff799
to
3162063
Compare
* [VisBuilder] Add Capability to generate dynamic vega In this PR, we add the capability for Visbuilder to generate dynamic Vega and Vega-Lite specifications based on user settings and aggregation configurations. * developed functions buildVegaSpecViaVega and buildVegaSpecViaVegaLite that can create either Vega or Vega-Lite specifications depending on the complexity of the visualization. * added VegaSpec and VegaLiteSpec interfaces to provide better type checking * broken down the specification building into smaller, reusable components (like buildEncoding, buildMark, buildLegend, buildTooltip) to make the code more maintainable and easier to extend. * added flattenDataHandler to prepare and transform data for use in Vega visualizations Issue Resolve #7067 Signed-off-by: Anan Zhuang <[email protected]> * fix PR comments * update file and functions names * fix type errors * fix area chart Signed-off-by: Anan Zhuang <[email protected]> * add unit tests Signed-off-by: Anan Zhuang <[email protected]> * enable embeddable for useVega Signed-off-by: Anan Zhuang <[email protected]> * remove buildVegaScales due to split it to smaller modules Signed-off-by: Anan Zhuang <[email protected]> * fix date for vega Signed-off-by: Anan Zhuang <[email protected]> * fix test Signed-off-by: Anan Zhuang <[email protected]> * Changeset file for PR #7288 created/updated --------- Signed-off-by: Anan Zhuang <[email protected]> Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com> (cherry picked from commit faaa45c) Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
* [VisBuilder] Add Capability to generate dynamic vega In this PR, we add the capability for Visbuilder to generate dynamic Vega and Vega-Lite specifications based on user settings and aggregation configurations. * developed functions buildVegaSpecViaVega and buildVegaSpecViaVegaLite that can create either Vega or Vega-Lite specifications depending on the complexity of the visualization. * added VegaSpec and VegaLiteSpec interfaces to provide better type checking * broken down the specification building into smaller, reusable components (like buildEncoding, buildMark, buildLegend, buildTooltip) to make the code more maintainable and easier to extend. * added flattenDataHandler to prepare and transform data for use in Vega visualizations Issue Resolve #7067 Signed-off-by: Anan Zhuang <[email protected]> * fix PR comments * update file and functions names * fix type errors * fix area chart Signed-off-by: Anan Zhuang <[email protected]> * add unit tests Signed-off-by: Anan Zhuang <[email protected]> * enable embeddable for useVega Signed-off-by: Anan Zhuang <[email protected]> * remove buildVegaScales due to split it to smaller modules Signed-off-by: Anan Zhuang <[email protected]> * fix date for vega Signed-off-by: Anan Zhuang <[email protected]> * fix test Signed-off-by: Anan Zhuang <[email protected]> * Changeset file for PR #7288 created/updated --------- Signed-off-by: Anan Zhuang <[email protected]> Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com> (cherry picked from commit faaa45c) Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
* [VisBuilder] Add Capability to generate dynamic vega In this PR, we add the capability for Visbuilder to generate dynamic Vega and Vega-Lite specifications based on user settings and aggregation configurations. * developed functions buildVegaSpecViaVega and buildVegaSpecViaVegaLite that can create either Vega or Vega-Lite specifications depending on the complexity of the visualization. * added VegaSpec and VegaLiteSpec interfaces to provide better type checking * broken down the specification building into smaller, reusable components (like buildEncoding, buildMark, buildLegend, buildTooltip) to make the code more maintainable and easier to extend. * added flattenDataHandler to prepare and transform data for use in Vega visualizations Issue Resolve #7067 --------- (cherry picked from commit faaa45c) 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> Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com>
* [VisBuilder] Add Capability to generate dynamic vega In this PR, we add the capability for Visbuilder to generate dynamic Vega and Vega-Lite specifications based on user settings and aggregation configurations. * developed functions buildVegaSpecViaVega and buildVegaSpecViaVegaLite that can create either Vega or Vega-Lite specifications depending on the complexity of the visualization. * added VegaSpec and VegaLiteSpec interfaces to provide better type checking * broken down the specification building into smaller, reusable components (like buildEncoding, buildMark, buildLegend, buildTooltip) to make the code more maintainable and easier to extend. * added flattenDataHandler to prepare and transform data for use in Vega visualizations Issue Resolve #7067 --------- (cherry picked from commit faaa45c) 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> Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com>
Description
In this PR, we add the capability for Visbuilder to generate dynamic Vega and Vega-Lite specifications based on user settings and aggregation configurations. Some hightlighs:
buildVegaSpecViaVega
andbuildVegaSpecViaVegaLite
that can create either Vega or Vega-Lite specifications depending on the complexity of the visualization.VegaSpec
andVegaLiteSpec
interfaces to provide better type checkingNote: In this current implementation, we directly utilize the existing visualization and style configurations from Visbuilder. This approach maintains consistency with the current feature set and minimizes changes in this pull request. For future enhancements, we plan to introduce dedicated Vega-specific properties within both the visualization and style slices. This will allow us to accommodate new Vega-related settings and provide more granular control over Vega visualizations without affecting the existing Visbuilder functionality.
Issues Resolved (Partially)
#7067
Screenshot
2024-07-17_10-27-24.mp4
Testing the changes
Changelog
Check List
yarn test:jest
yarn test:jest_integration