Skip to content

Instantly share code, notes, and snippets.

@ederign

ederign/Dashboard.java Secret

Created Apr 6, 2021
Embed
What would you like to do?
import org.dashbuilder.dataset.*
import org.dashbuilder.displayer.DisplayerSettings;
import org.dashbuilder.dsl.factory.component.ComponentFactory;
import org.dashbuilder.dsl.factory.dashboard.DashboardFactory;
import org.dashbuilder.dsl.model.*
import org.dashbuilder.dsl.serialization.*
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.navigation.NavigationFactory.*;
import static org.dashbuilder.dsl.factory.page.PageFactory.*;
public class SimpleDashboard {
public static void main(String[] args) {
DataSet dataSet = newDataSetBuilder().column("Country", ColumnType.LABEL)
.column("Population", ColumnType.NUMBER)
.row("Brazil", "211")
.row("United States", "328")
.row("Cuba", "11")
.row("India", "1366")
.row("China", "1398")
.buildDataSet();
DisplayerSettings populationBar = newBarChartSettings().subType_Column()
.width(800)
.height(600)
.dataset(dataSet)
.column("Country")
.column("Population")
.buildSettings();
Page page = page("Countries Population",
row("<h3> Countries Population </h3>"),
row(ComponentFactory.displayer(populationBar)));
Navigation navigation = navigation(group("Countries Information", item(page)));
Dashboard populationDashboard = DashboardFactory.dashboard(asList(page), navigation);
DashboardExporter.get().export(populationDashboard,
"/path/to/export.zip",
ExportType.ZIP);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment