Here is an example:
import org.jfree.chart.plot.PlotOrientation
import org.jfree.chart.{ChartFactory => cf, JFreeChart}
import org.jfree.data.xy.XYDataset
package object sfreechart {
object xyl {
def xyline(
dataset: XYDataset,
title: String = "XY line chart", xAxisLabel: String = "x", yAxisLabel: String = "y",
orientation: PlotOrientation = PlotOrientation.VERTICAL, legend: Boolean = true,
tooltips: Boolean = true, urls: Boolean = true
): JFreeChart = {
cf.createXYLineChart(
title, xAxisLabel, yAxisLabel,
dataset, orientation, legend,
tooltips, urls
)
}
}
}
I am just trying to provide sensible defaults for a plotting function in jFreeChart, so that a chart can be created without much ceremony. The above code works fine, but involves some boring boilerplates. Is there a cleverer trick?
Ideally I should only need to do something like this:
val xyline = cf.createXYLineChart.setDefaults(title = "XY line chart", ...)