diff options
author | Robert Jaros <rjaros@finn.pl> | 2019-07-16 16:50:28 +0200 |
---|---|---|
committer | Robert Jaros <rjaros@finn.pl> | 2019-07-16 16:50:28 +0200 |
commit | 403146760ae578daca974e12f1f9f72b5937a558 (patch) | |
tree | 69bdea38e0e2c0fbf15c4f4f55e0773958d0a408 /kvision-modules | |
parent | 43ab683f58a940999cf3be9d3a03f35c481541ef (diff) | |
download | kvision-403146760ae578daca974e12f1f9f72b5937a558.tar.gz kvision-403146760ae578daca974e12f1f9f72b5937a558.tar.bz2 kvision-403146760ae578daca974e12f1f9f72b5937a558.zip |
Fixed chart updates (#73)
Diffstat (limited to 'kvision-modules')
-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 |