erp-platform/ui/src/views/chart/utils.ts
Sedat ÖZTÜRK e1a9562b22 init project
2025-05-06 09:45:49 +03:00

60 lines
2 KiB
TypeScript

import { ChartDto } from '@/proxy/charts'
import { getChartSelect } from '@/proxy/charts/chart.service'
import CustomStore from 'devextreme/data/custom_store'
export function getChartOptionsDto(chartCode: string, chartDto: ChartDto, filter?: string) {
if (!chartDto || !chartCode) {
return undefined
}
const dataSource = {
store: new CustomStore({
load: () => {
return getChartSelect(chartCode, filter)
},
}),
filter: null,
paginate: false,
}
const options = {
dataSource: dataSource,
adjustOnZoom: chartDto.commonDto?.adjustOnZoom ?? true,
containerBackgroundColor: chartDto.commonDto?.containerBackgroundColor ?? '#FFFFFF',
disabled: chartDto.commonDto?.disabled ?? false,
palette: chartDto.commonDto?.palette ?? 'Material',
paletteExtensionMode: chartDto.commonDto?.paletteExtensionMode ?? 'blend',
//theme: s(chartDto.commonDto?.theme, 'generic.light'),
title: chartDto.titleDto,
size: chartDto.sizeDto?.useSize ? chartDto.sizeDto : null,
legend: chartDto.legendDto,
margin: chartDto.marginDto,
adaptiveLayout: chartDto.adaptivelayoutDto,
defaultPane: chartDto.commonDto?.defaultPane,
scrollBar: chartDto.scrollBarDto,
zoomAndPan: chartDto.zoomAndPanDto,
animation: chartDto.animationDto,
export: chartDto.exportDto,
crosshair: chartDto.crosshairDto,
argumentAxis: chartDto.argumentAxisDto,
valueAxis: chartDto.valueAxisDto,
tooltip: chartDto.tooltipDto,
panes: chartDto.panesDto?.length > 0 ? chartDto.panesDto : undefined,
series: chartDto.seriesDto?.length > 0 ? chartDto.seriesDto : undefined,
commonSeriesSettings: chartDto.commonSeriesSettingsDto,
commonPaneSettings: chartDto.commonPaneSettingsDto,
commonAxisSettings: chartDto.commonAxisSettingsDto,
annotations: chartDto.annotationsDto,
commonAnnotationSettings: chartDto.commonAnnotationSettingsDto,
loadingIndicator: {
enabled: true,
},
}
return options
}