Skip to content

Instantly share code, notes, and snippets.

Created April 29, 2021 21:21
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Minimal Java Code to create Dashboards using Java for Dashbuilder
package org.kie.dashbuilder;
import org.dashbuilder.dataset.ColumnType;
import org.dashbuilder.dsl.serialization.DashboardExporter;
import org.dashbuilder.dsl.serialization.DashboardExporter.ExportType;
import static java.util.Arrays.asList;
import static org.dashbuilder.dataset.DataSetFactory.newDataSetBuilder;
import static org.dashbuilder.displayer.DisplayerSettingsFactory.newBarChartSettings;
import static org.dashbuilder.dsl.factory.component.ComponentFactory.displayer;
import static org.dashbuilder.dsl.factory.dashboard.DashboardFactory.dashboard;
import static;
import static;
public class PopulationDashboard {
public static void main(String[] args) {
// creates a data set with pure Java code - external sources can be used as well
var dataSet = newDataSetBuilder().column("Country", ColumnType.LABEL)
.column("Population", ColumnType.NUMBER)
.row("China", "1439323776")
.row("India", "1380004385")
.row("United States", "331002651")
.row("Indonesia", "273523615")
.row("Pakistan", "220892340")
.row("Brazil", "212559417")
.row("Nigeria", "206139589")
.row("Bangladesh", "164689383")
.row("Russia", "145934462")
.row("Mexico", "128932753")
// a bar chart configuration that is used to visualize the data set
var popBarChart = newBarChartSettings().subType_Column()
// a page with a HTML header and the displayer that uses the bar chart configuration
var page = page("Countries Population",
row("<h3> Countries Population</h3>"),
// finally exports the dashboard to a local ZIP file
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment