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

fix(components): fix types of logit scale #144 #152

Merged
merged 1 commit into from
Apr 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions components/src/preact/components/chart.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,9 @@ export const ChartStory: StoryObj<GsChartProps> = {
options: {
animation: false,
scales: {
// @ts-expect-error-next-line -- chart.js typings are not complete with custom scales
y: getYAxisScale('logarithmic'),
},
},
},
yAxisScaleType: 'logarithmic',
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ const PrevalenceOverTimeBarChart = ({
options: {
animation: false,
scales: {
// @ts-expect-error-next-line -- chart.js typings are not complete with custom scales
y: getYAxisScale(yAxisScaleType),
},
plugins: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ const PrevalenceOverTimeBubbleChart = ({ data, yAxisScaleType }: PrevalenceOverT
callback: (value) => addUnit(firstDate, value as number).toString(),
},
},
// @ts-expect-error-next-line -- chart.js typings are not complete with custom scales
y: getYAxisScale(yAxisScaleType),
},
plugins: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ const PrevalenceOverTimeLineChart = ({
options: {
animation: false,
scales: {
// @ts-expect-error-next-line -- chart.js typings are not complete with custom scales
y: getYAxisScale(yAxisScaleType),
},
plugins: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ const RelativeGrowthAdvantageChart = ({ data, yAxisScaleType }: RelativeGrowthAd
options: {
animation: false,
scales: {
// @ts-expect-error-next-line -- chart.js typings are not complete with custom scales
y: getYAxisScale(yAxisScaleType),
},
plugins: {
Expand Down
11 changes: 9 additions & 2 deletions components/src/preact/shared/charts/LogitScale.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Scale } from 'chart.js';
import { type Chart } from 'chart.js/dist/types';
import { type Chart, type CoreScaleOptions, Scale } from 'chart.js';

export class LogitScale extends Scale {
static id = 'logit';
Expand Down Expand Up @@ -39,3 +38,11 @@ export class LogitScale extends Scale {
return this.getPixelForDecimal(decimal);
}
}

declare module 'chart.js' {
export interface CartesianScaleTypeRegistry {
logit: {
options: CoreScaleOptions;
};
}
}