Use enum for PlotType

This commit is contained in:
Kenshin Abe committed 2024-01-26 15:27:34 +09:00
1 parent 4147b01c56
commit aef91deac2
2 files changed
+7 -4

No files matched your search

+5 -2
View File
@@ -445,11 +445,14 @@ type PlotResponse = {
data: plotly.Data[]
layout: plotly.Layout
}
export enum PlotType {
Contour = "contour",
}
export const getPlotAPI = (
studyId: number,
plotName: string
plotType: PlotType
): Promise<PlotResponse> => {
return axiosInstance
.get<PlotResponse>(`/api/studies/${studyId}/plot/${plotName}`)
.get<PlotResponse>(`/api/studies/${studyId}/plot/${plotType}`)
.then<PlotResponse>((res) => res.data)
}
@@ -16,7 +16,7 @@ import { plotlyDarkTemplate } from "./PlotlyDarkMode"
import { useMergedUnionSearchSpace } from "../searchSpace"
import { getAxisInfo } from "../graphUtil"
import { useQuery } from "../urlQuery"
import { getPlotAPI } from "../apiClient"
import { getPlotAPI, PlotType } from "../apiClient"
const plotDomId = "graph-contour"
@@ -39,7 +39,7 @@ const ContourBackend: FC<{
if (studyId === undefined) {
return
}
getPlotAPI(studyId, "contour")
getPlotAPI(studyId, PlotType.Contour)
.then(({ data, layout }) => {
plotly.react(plotDomId, data, layout)
})