diff --git a/src/main/java/tornadofx/Charts.kt b/src/main/java/tornadofx/Charts.kt index e9130a776..13350464e 100644 --- a/src/main/java/tornadofx/Charts.kt +++ b/src/main/java/tornadofx/Charts.kt @@ -1,5 +1,6 @@ package tornadofx +import javafx.collections.FXCollections import javafx.collections.ObservableList import javafx.event.EventTarget import javafx.scene.chart.* @@ -33,38 +34,38 @@ fun PieChart.data(value: Map) = value.forEach { data(it.key, it. /** * Create a LineChart with optional title, axis and add to the parent pane. The optional op will be performed on the new instance. */ -fun EventTarget.linechart(title: String? = null, x: Axis, y: Axis, op: LineChart.() -> Unit = {}) = - LineChart(x, y).attachTo(this, op) { it.title = title } +fun EventTarget.linechart(title: String? = null, x: Axis, y: Axis, data: ObservableList> = FXCollections.observableArrayList(), op: LineChart.() -> Unit = {}) = + LineChart(x, y, data).attachTo(this, op) { it.title = title } /** * Create an AreaChart with optional title, axis and add to the parent pane. The optional op will be performed on the new instance. */ -fun EventTarget.areachart(title: String? = null, x: Axis, y: Axis, op: AreaChart.() -> Unit = {}) = - AreaChart(x, y).attachTo(this, op){ it.title = title } +fun EventTarget.areachart(title: String? = null, x: Axis, y: Axis, data: ObservableList> = FXCollections.observableArrayList(), op: AreaChart.() -> Unit = {}) = + AreaChart(x, y, data).attachTo(this, op){ it.title = title } /** * Create a BubbleChart with optional title, axis and add to the parent pane. The optional op will be performed on the new instance. */ -fun EventTarget.bubblechart(title: String? = null, x: Axis, y: Axis, op: BubbleChart.() -> Unit = {}) = - BubbleChart(x, y).attachTo(this,op){ it.title = title } +fun EventTarget.bubblechart(title: String? = null, x: Axis, y: Axis, data: ObservableList> = FXCollections.observableArrayList(), op: BubbleChart.() -> Unit = {}) = + BubbleChart(x, y, data).attachTo(this,op){ it.title = title } /** * Create a ScatterChart with optional title, axis and add to the parent pane. The optional op will be performed on the new instance. */ -fun EventTarget.scatterchart(title: String? = null, x: Axis, y: Axis, op: ScatterChart.() -> Unit = {}) = - ScatterChart(x, y).attachTo(this,op){ it.title = title } +fun EventTarget.scatterchart(title: String? = null, x: Axis, y: Axis, data: ObservableList> = FXCollections.observableArrayList(), op: ScatterChart.() -> Unit = {}) = + ScatterChart(x, y, data).attachTo(this,op){ it.title = title } /** * Create a BarChart with optional title, axis and add to the parent pane. The optional op will be performed on the new instance. */ -fun EventTarget.barchart(title: String? = null, x: Axis, y: Axis, op: BarChart.() -> Unit = {}) = - BarChart(x, y).attachTo(this, op){ it.title = title } +fun EventTarget.barchart(title: String? = null, x: Axis, y: Axis, data: ObservableList> = FXCollections.observableArrayList(), op: BarChart.() -> Unit = {}) = + BarChart(x, y, data).attachTo(this, op){ it.title = title } /** * Create a BarChart with optional title, axis and add to the parent pane. The optional op will be performed on the new instance. */ -fun EventTarget.stackedbarchart(title: String? = null, x: Axis, y: Axis, op: StackedBarChart.() -> Unit = {}) = - StackedBarChart(x, y).attachTo(this, op) { it.title = title } +fun EventTarget.stackedbarchart(title: String? = null, x: Axis, y: Axis, data: ObservableList> = FXCollections.observableArrayList(), op: StackedBarChart.() -> Unit = {}) = + StackedBarChart(x, y, data).attachTo(this, op) { it.title = title } /** * Add a new XYChart.Series with the given name to the given Chart. Optionally specify a list data for the new series or