aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Jaros <rjaros@finn.pl>2019-07-16 16:50:28 +0200
committerRobert Jaros <rjaros@finn.pl>2019-07-16 16:50:28 +0200
commit403146760ae578daca974e12f1f9f72b5937a558 (patch)
tree69bdea38e0e2c0fbf15c4f4f55e0773958d0a408
parent43ab683f58a940999cf3be9d3a03f35c481541ef (diff)
downloadkvision-403146760ae578daca974e12f1f9f72b5937a558.tar.gz
kvision-403146760ae578daca974e12f1f9f72b5937a558.tar.bz2
kvision-403146760ae578daca974e12f1f9f72b5937a558.zip
Fixed chart updates (#73)
-rw-r--r--kvision-modules/kvision-chart/src/main/kotlin/pl/treksoft/kvision/chart/ChartCanvas.kt8
-rw-r--r--kvision-modules/kvision-chart/src/main/kotlin/pl/treksoft/kvision/chart/js/Chart.kt1
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