From 0da5f7d7b62d8d4183dade2a185eb688d8099b93 Mon Sep 17 00:00:00 2001 From: Robert Jaros Date: Tue, 24 Sep 2019 13:11:53 +0200 Subject: Basic support for Chart.js plugins (#81) --- .../src/main/kotlin/pl/treksoft/kvision/chart/Chart.kt | 9 +++++++++ .../src/main/kotlin/pl/treksoft/kvision/chart/Configuration.kt | 4 +++- 2 files changed, 12 insertions(+), 1 deletion(-) (limited to 'kvision-modules/kvision-chart/src/main/kotlin/pl/treksoft') 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 } } -- cgit