Skip to content

Conversation

iMoses
Copy link
Contributor

@iMoses iMoses commented Oct 1, 2025

No description provided.

@iMoses iMoses requested review from alantreadway and a team as code owners October 1, 2025 13:27
this.isRollingBack = false;
}

private predictAxes(seriesType: SeriesType, userSeriesOptions?: any, data?: DatumDefault[]) {
Copy link
Member

Choose a reason for hiding this comment

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

Could we easily extract this to a utility function, this doesn't feel like the best place for this logic to live?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure. I started by making it a standalone function, but this was the only part of the code that actually uses it, and I didn't want to breakdown the optionsGraph approach.

const { layoutBox } = ctx;

const seriesRect = layoutBox.clone().shrink(this.modulesManager.getModule<any>('seriesArea').getPadding());
const seriesAreaModule = this.modulesManager.getModule('seriesArea') as any;
Copy link
Member

Choose a reason for hiding this comment

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

Are the as any casts a temporary measure?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In this specific case you can see that it was already case to any in here: getModule<any>('seriesArea')
We can obviously improve on it, but not sure if it'll be in this iteration.

for (let index = 0; index < options.length; index++) {
const axisOptions = options[index];
const axis = axisRegistry.create(axisOptions.type, moduleContext);
const axis = ModuleRegistry.getAxisModule(axisOptions.type)!.create(moduleContext) as any;
Copy link
Member

Choose a reason for hiding this comment

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

Are the as any casts a temporary measure?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, it's temporary, though we should probably find a better way to handle this.

private createSeries(seriesOptions: SeriesOptionsTypes): UnknownSeries {
const seriesInstance = seriesRegistry.create(seriesOptions.type, this.getModuleContext()) as UnknownSeries;
const seriesModule = ModuleRegistry.getSeriesModule(seriesOptions.type);
const seriesInstance = seriesModule!.create(this.getModuleContext()) as UnknownSeries;
Copy link
Member

Choose a reason for hiding this comment

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

Do we need the ! here and below?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, because seriesModule can also be undefined.
We could change the logic to throw in such cases, to simplify the types, but it's a bigger change.

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.

2 participants