mirror of
https://github.com/h-sphere/sql-seal-charts.git
synced 2026-07-22 05:37:34 +00:00
chore: fixing issue with types
This commit is contained in:
parent
8bbd976056
commit
3917766227
2 changed files with 8 additions and 5 deletions
|
|
@ -13,7 +13,6 @@
|
|||
},
|
||||
"keywords": [
|
||||
"obsidian",
|
||||
"plugin",
|
||||
"sqlseal",
|
||||
"charts",
|
||||
"visualisation",
|
||||
|
|
|
|||
|
|
@ -28,12 +28,16 @@ export class ChartRenderer implements RendererConfig {
|
|||
render: ({ columns, data }: { columns: string[], data: Record<string, unknown>[]}) => {
|
||||
const { functions, variables } = prepareDataVariables({ columns, data })
|
||||
const parsedConfig = parseCode(config.config, functions, variables)
|
||||
const dataset = [{ id: 'data', source: data }, ...(parsedConfig.dataset ?? [])]
|
||||
parsedConfig.dataset = dataset
|
||||
if (!parsedConfig || typeof parsedConfig !== 'object') {
|
||||
throw new Error('Issue with parsing config')
|
||||
}
|
||||
const configRecord = parsedConfig as Record<string, any>
|
||||
const dataset = [{ id: 'data', source: data }, ...(configRecord.dataset ?? [])]
|
||||
configRecord.dataset = dataset
|
||||
|
||||
if (isRendered) {
|
||||
// Data update
|
||||
chart?.setOption(parsedConfig)
|
||||
chart?.setOption(configRecord)
|
||||
return
|
||||
}
|
||||
|
||||
|
|
@ -45,7 +49,7 @@ export class ChartRenderer implements RendererConfig {
|
|||
const width = box.width
|
||||
const height = box.height
|
||||
chart = echarts.init(chartDiv, null, { height: height, width: width, })
|
||||
chart.setOption(parsedConfig)
|
||||
chart.setOption(configRecord)
|
||||
isRendered = true
|
||||
})
|
||||
},
|
||||
|
|
|
|||
Loading…
Reference in a new issue