0

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", ...)
0

1 Answer 1

1

There isn't any such trick. Also, IMHO, there really isn't any boilerplate here. Its the minimum you could write to convey this requirement.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.