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

Split out global chart options from ones specific to the colour theme or chart type #3507

Closed

Conversation

helenb
Copy link
Collaborator

@helenb helenb commented Feb 24, 2025

What is the context of this PR?

Demo for @precious-onyenaucheya-ons to show how we might split the chart options into ones that are global, for all chart types, and ones that need to be updated for each chart.

How to review this PR

Have a look at the code changes and test them to see if they make sense.
Either merge them to your PR if you would like to, or copy and adapt if you would prefer.

Checklist

This needs to be completed by the person raising the PR.

  • I have selected the correct Assignee
  • I have linked the correct Issue

@helenb helenb requested a review from a team as a code owner February 24, 2025 14:53
@helenb helenb marked this pull request as draft February 24, 2025 14:53
@@ -1,6 +1,6 @@
/* this contains global options for all charts */
class ChartOptions {
constructor(theme, title, type) {
class CommonChartOptions {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I've renamed the class and the file to reflect the fact that this is now common chart options only, and to differentiate it from the SpecificChartOptions class.

class ChartOptions {
constructor(theme, title, type) {
class CommonChartOptions {
constructor() {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We no longer need to pass in the type of chart or the theme, as any options that need to check these have moved to SpecificChartOptions

chart: {
backgroundColor: 'transparent',
style: {
fontFamily: '"OpenSans", "Helvetica Neue", arial, sans-serif',
color: '#222222',
},
},
legend: {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I've moved all the legend configuration to SpecificChartOptions, even though some of it is general, in order to avoid the merging of the options getting too complicated - it's easier to merge in all the top level values for each key in the options object.

@helenb
Copy link
Collaborator Author

helenb commented Feb 26, 2025

Closing this MR as @precious-onyenaucheya-ons has now incorporated the changes in #3506

@helenb helenb closed this Feb 26, 2025
@helenb helenb deleted the feature/adjustments-to-chart-options branch February 27, 2025 14:51
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.

1 participant