Skip to content
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

Dynamic configuration and visual props #29

Merged
merged 20 commits into from
Jul 18, 2024
Merged

Dynamic configuration and visual props #29

merged 20 commits into from
Jul 18, 2024

Conversation

Rohit1508
Copy link
Contributor

No description provided.

Copy link

github-actions bot commented Mar 28, 2024

File Coverage
All files 78%
src/index.ts 0%
src/main/custom-chart-context.ts 85%
src/main/post-message-event-bridge.ts 81%
src/main/util.ts 75%
src/react/use-custom-chart-context.tsx 83%
src/react/mocks/custom-chart-context-mock.ts 76%
src/utils/conditional-formatting/conditional-formatting.ts 70%

Minimum allowed coverage is 0%

Generated by 🐒 cobertura-action against e7a234d

@Rohit1508 Rohit1508 requested a review from chetan1507 March 29, 2024 20:39
],
];
if (visualProps?.length !== 0) {
if (visualProps?.accordion?.datalabels) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

whats the value in this change? I see no difference?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@@ -367,7 +392,30 @@ const renderChart = async (ctx: CustomChartContext): Promise<void> => {
},
],
},
],
];
if (visualProps?.length !== 0) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is not an array but an object right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

element is an array, visualPropEditordefinition is an Object

@@ -174,11 +182,8 @@ function render(ctx: CustomChartContext) {
plugins: {
// Change options for ALL labels of THIS CHART
datalabels: {
display: allowLabels ? 'auto' : false,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we seem to have removed a lot of properties... is this working as expected?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is working

];
if (yColumns?.columns.length) {
for (let i = 0; i < yColumns.columns.length; i++) {
configDefinition[0].columnSections.push({
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where are we using this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This I have added for an example purpose, when we are adding measures to y-axis, a new layer will be created with the same.

@@ -21,10 +21,14 @@ import {
AppConfig,
ChartConfig,
ChartModel,
SuccessValidationResponse,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you help resolve dependency cycles?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To resolve this we need to break the types structure which we have defined

@@ -37,7 +40,7 @@ const visualPropKeyMap = {
2: 'accordion.datalabels',
};

const numberFormatter = value => {
const numberFormatter = (value) => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pls add type for value

const labelColor = _.get(
chartModel.visualProps,
visualPropKeyMap[1],
'blue',
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if blue is constant, can we pick from a constant?

color: 'blue',
textStrokeColor: 'white',
textStrokeWidth: 5,
display: allowLabels,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

display takes true now?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://chartjs-plugin-datalabels.netlify.app/guide/positioning.html#rotation

will depend on implementation, true is also a valid value as mentioned above in the documentation

Comment on lines -178 to -181
formatter: value => numberFormatter(value),
color: 'blue',
textStrokeColor: 'white',
textStrokeWidth: 5,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how are these properties working today?

key: 'y',
label: 'Custom Y Axis',
renderChart: (ctx) => renderChart(ctx),
chartConfigEditorDefinition: (
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for backward compatibility verification should we keep this as it is?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have checked the backwards compatibilty it is working for both object and function we can keep it like this for a sample chart.

@@ -8,6 +8,7 @@
* Copyright: ThoughtSpot Inc. 2023
*/

import { VisualPropEditorDefinition } from '@thoughtspot/ts-chart-sdk';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we create a copy of this example with ur new changes? In that way, we can make sure the backward compatibility validation is in place for each version?

Comment on lines 635 to 662
if (this.chartContextProps.validateConfig) {
const validationResponse =
this.chartContextProps.validateConfig(
payload.chartConfig,
this.chartModel,
);
if (validationResponse.isValid) {
const currentConfigState = {
config: {
...this.chartModel.config,
chartConfig: payload.chartConfig,
},
};
const chartConfigEditorDefinition =
this.getChartConfigEditorDefinition(
currentConfigState,
);

const visualPropEditorDefinition =
this.getVisualPropEditorDefinition(
currentConfigState,
);
return {
...validationResponse,
visualPropEditorDefinition,
chartConfigEditorDefinition,
};
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

duplicate code for TSToChartEvent.VisualPropsValidate event.
Should we move and reuse?

@harshmeetTS harshmeetTS merged commit f98ecbe into main Jul 18, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants