diff options
Diffstat (limited to 'kvision-modules/kvision-chart')
-rw-r--r-- | kvision-modules/kvision-chart/src/main/kotlin/pl/treksoft/kvision/chart/ChartCanvas.kt | 8 | ||||
-rw-r--r-- | kvision-modules/kvision-chart/src/main/kotlin/pl/treksoft/kvision/chart/js/Chart.kt | 1 |
2 files changed, 7 insertions, 2 deletions
diff --git a/kvision-modules/kvision-chart/src/main/kotlin/pl/treksoft/kvision/chart/ChartCanvas.kt b/kvision-modules/kvision-chart/src/main/kotlin/pl/treksoft/kvision/chart/ChartCanvas.kt index 8d7c49a7..a37d0a8f 100644 --- a/kvision-modules/kvision-chart/src/main/kotlin/pl/treksoft/kvision/chart/ChartCanvas.kt +++ b/kvision-modules/kvision-chart/src/main/kotlin/pl/treksoft/kvision/chart/ChartCanvas.kt @@ -38,7 +38,9 @@ internal class ChartCanvas( var configuration: Configuration = configuration set(value) { field = value - jsChart?.config = value.toJs(this::translate) + val newConfig = value.toJs(this::translate) + if (newConfig.data != null) jsChart?.data = newConfig.data!! + if (newConfig.options != null) jsChart?.options = newConfig.options!! jsChart?.update() } @@ -46,7 +48,9 @@ internal class ChartCanvas( override fun render(): VNode { if (lastLanguage != null && lastLanguage != I18n.language) { - jsChart?.config = configuration.toJs(this::translate) + val newConfig = configuration.toJs(this::translate) + if (newConfig.data != null) jsChart?.data = newConfig.data!! + if (newConfig.options != null) jsChart?.options = newConfig.options!! jsChart?.update() } return render("canvas") diff --git a/kvision-modules/kvision-chart/src/main/kotlin/pl/treksoft/kvision/chart/js/Chart.kt b/kvision-modules/kvision-chart/src/main/kotlin/pl/treksoft/kvision/chart/js/Chart.kt index 7fb47bb0..e6bd9841 100644 --- a/kvision-modules/kvision-chart/src/main/kotlin/pl/treksoft/kvision/chart/js/Chart.kt +++ b/kvision-modules/kvision-chart/src/main/kotlin/pl/treksoft/kvision/chart/js/Chart.kt @@ -61,6 +61,7 @@ open external class Chart { open var config: ChartConfiguration = definedExternally open var data: ChartData = definedExternally + open var options: ChartOptions = definedExternally open fun destroy(): Any = definedExternally open fun update(duration: Any? = definedExternally, lazy: Any? = definedExternally): Any = definedExternally open fun render(duration: Any? = definedExternally, lazy: Any? = definedExternally): Any = definedExternally |