Skip to content

cutecharts/cutecharts-func.java

Repository files navigation

cutecharts.java logo

🎨A hand drawing style charts library in functional Java.

 📣 Description

This is a functional version of cutecharts.java which I want try to write Java on non-Java. 🐶

Definitely, It is more fun to make something has more possibilities.

🔖 Documentation

All the configurations detail you can find on there chart.xkcd.

📝 Useage

Using the Functional stuff, it should be JDK8 at least.

It uses the Lombok plugin, you may need access your IDE support.

Import Dependency

Maven

<dependency>
    <groupId>com.koy</groupId>
    <artifactId>cutecharts-func</artifactId>
    <version>1.0.0</version>
</dependency>

Gradle

compile group: 'com.koy', name: 'cutecharts-func', version: '1.0.0'

Code Demo

Basically, you can make it like this.

 Chart line = Chart.newChart(ChartType.LINE)
                .setGlobalOptions(
                        GlobalOptions.setTitle("Demo-Line"),
                        GlobalOptions.setXLabel("X-axis Week"),
                        GlobalOptions.setYLabel("Y-axis Amount")
                ).setSeriesOptions(
                        SeriesOptions.setBackgroundColor("orange")
                )
                .setDataLabels(1, 2, 3, 4, 5, 6, 7)
                .setDataSeriesOptions(
                        DataSet.addDataSet("Beer", 1, 2, 3, 4, 2, 5, 4),
                        DataSet.addDataSet("Juice", 1, 4, 7, 4, 1, 3, 2)
                )
                .build();

  RenderExecutor.renderToPath("./").accept(line);

Absolutely, you can be more functional !

   Chart line = setTitle("Demo-Line")
                   .and(setXLabel("X-axis Week"))
                   .and(setYLabel("Y-axis Amount"))
                   .and(setBackgroundColor("orange"))
                   .and(addDataSet("Beer", 1, 2, 3, 4, 2, 5, 4))
                   .and(addDataSet("Juice", 1, 4, 7, 4, 1, 3, 2))
                   .and(setDataLabels(1, 2, 3, 4, 5, 6, 7))
                   .apply(chartSupplier(ChartType.LINE).get());

   RenderExecutor.renderToPath("./line.html").accept(line);

line

📃 License

MIT ©Koy