aboutsummaryrefslogtreecommitdiff
path: root/kvision-modules
diff options
context:
space:
mode:
authorRobert Jaros <rjaros@finn.pl>2019-09-24 13:11:53 +0200
committerRobert Jaros <rjaros@finn.pl>2019-09-24 13:11:53 +0200
commit0da5f7d7b62d8d4183dade2a185eb688d8099b93 (patch)
tree3f17a37153e11390a9386d11fb028e98e3512b9c /kvision-modules
parenta043e23bc48b5c900f2282a8272c2827a345be55 (diff)
downloadkvision-0da5f7d7b62d8d4183dade2a185eb688d8099b93.tar.gz
kvision-0da5f7d7b62d8d4183dade2a185eb688d8099b93.tar.bz2
kvision-0da5f7d7b62d8d4183dade2a185eb688d8099b93.zip
Basic support for Chart.js plugins (#81)
Diffstat (limited to 'kvision-modules')
-rw-r--r--kvision-modules/kvision-chart/src/main/kotlin/pl/treksoft/kvision/chart/Chart.kt9
-rw-r--r--kvision-modules/kvision-chart/src/main/kotlin/pl/treksoft/kvision/chart/Configuration.kt4
2 files changed, 12 insertions, 1 deletions
diff --git a/kvision-modules/kvision-chart/src/main/kotlin/pl/treksoft/kvision/chart/Chart.kt b/kvision-modules/kvision-chart/src/main/kotlin/pl/treksoft/kvision/chart/Chart.kt
index 4681d9c4..91658476 100644
--- a/kvision-modules/kvision-chart/src/main/kotlin/pl/treksoft/kvision/chart/Chart.kt
+++ b/kvision-modules/kvision-chart/src/main/kotlin/pl/treksoft/kvision/chart/Chart.kt
@@ -23,6 +23,7 @@ package pl.treksoft.kvision.chart
import com.github.snabbdom.VNode
import pl.treksoft.kvision.chart.js.Chart.ChartConfiguration
+import pl.treksoft.kvision.chart.js.Chart as JsChart
import pl.treksoft.kvision.core.Container
import pl.treksoft.kvision.core.Widget
@@ -125,5 +126,13 @@ open class Chart(
this.add(chart)
return chart
}
+
+ fun registerPlugin(plugin: dynamic) {
+ JsChart.plugins.register(plugin)
+ }
+
+ fun unregisterPlugin(plugin: dynamic) {
+ JsChart.plugins.unregister(plugin)
+ }
}
}
diff --git a/kvision-modules/kvision-chart/src/main/kotlin/pl/treksoft/kvision/chart/Configuration.kt b/kvision-modules/kvision-chart/src/main/kotlin/pl/treksoft/kvision/chart/Configuration.kt
index 91944e74..ec69795b 100644
--- a/kvision-modules/kvision-chart/src/main/kotlin/pl/treksoft/kvision/chart/Configuration.kt
+++ b/kvision-modules/kvision-chart/src/main/kotlin/pl/treksoft/kvision/chart/Configuration.kt
@@ -751,7 +751,8 @@ data class ChartOptions(
val spanGaps: Boolean? = null,
val cutoutPercentage: Int? = null,
val circumference: Double? = null,
- val rotation: Double? = null
+ val rotation: Double? = null,
+ val plugins: dynamic = null
)
/**
@@ -783,6 +784,7 @@ fun ChartOptions.toJs(i18nTranslator: (String) -> (String)): dynamic {
if (cutoutPercentage != null) this.cutoutPercentage = cutoutPercentage
if (circumference != null) this.circumference = circumference
if (rotation != null) this.rotation = rotation
+ if (plugins != null) this.plugins = plugins
}
}