wicket-chartjs data

Java wrapper library for chartjs

License

License

Categories

Categories

JavaScript Languages Wicket User Interface Web Frameworks Data CRaSH General Purpose Libraries Utility
GroupId

GroupId

nl.crashdata.wicket-chartjs
ArtifactId

ArtifactId

wicket-chartjs-data
Last Version

Last Version

0.50
Release Date

Release Date

Type

Type

jar
Description

Description

wicket-chartjs data
Java wrapper library for chartjs

Download wicket-chartjs-data

How to add to project

<!-- https://jarcasting.com/artifacts/nl.crashdata.wicket-chartjs/wicket-chartjs-data/ -->
<dependency>
    <groupId>nl.crashdata.wicket-chartjs</groupId>
    <artifactId>wicket-chartjs-data</artifactId>
    <version>0.50</version>
</dependency>
// https://jarcasting.com/artifacts/nl.crashdata.wicket-chartjs/wicket-chartjs-data/
implementation 'nl.crashdata.wicket-chartjs:wicket-chartjs-data:0.50'
// https://jarcasting.com/artifacts/nl.crashdata.wicket-chartjs/wicket-chartjs-data/
implementation ("nl.crashdata.wicket-chartjs:wicket-chartjs-data:0.50")
'nl.crashdata.wicket-chartjs:wicket-chartjs-data:jar:0.50'
<dependency org="nl.crashdata.wicket-chartjs" name="wicket-chartjs-data" rev="0.50">
  <artifact name="wicket-chartjs-data" type="jar" />
</dependency>
@Grapes(
@Grab(group='nl.crashdata.wicket-chartjs', module='wicket-chartjs-data', version='0.50')
)
libraryDependencies += "nl.crashdata.wicket-chartjs" % "wicket-chartjs-data" % "0.50"
[nl.crashdata.wicket-chartjs/wicket-chartjs-data "0.50"]

Dependencies

compile (1)

Group / Artifact Type Version
com.fasterxml.jackson.core : jackson-annotations jar 2.9.4

Project Modules

There are no modules declared in this project.

java-chartjs

Maven metadata URI license

Java-chartjs provides you with a way to configure and use ChartJs from Java and Java-based web frameworks such as Apache Wicket.

Usage example

In Java:

SimpleChartJsConfigBuilder<SimpleChartJsXYDataPoint<LocalDate, Integer>> config =
	SimpleChartJsConfigBuilder.lineChart();

SortedMap<LocalDate, Integer> dataPoints = createUserCountMap();

config.data()
	.addDataset()
	.withDataPoints(dataPoints.entrySet(), SimpleChartJsXYDataPoint::new)
	.withLabel("activeUsers")
	.withFill(ChartJsFill.boundary(ChartJsBoundaryType.START))
	.withBorderColor(ChartJsRGBAColor.BLUE);

LocalDate smallestXValue = dataPoints.firstKey();

SimpleChartJsOptionsBuilder optionsBuilder = config.options();
optionsBuilder.withResponsive(true);
optionsBuilder.hoverConfig().withIntersect(true).withMode(ChartJsInteractionMode.NEAREST);
optionsBuilder.tooltipConfig().withIntersect(false).withMode(ChartJsInteractionMode.INDEX);

SimpleChartJsLocalDateAxisConfigBuilder xAxisBuilder =
	optionsBuilder.scalesConfig().withLocalDateXAxisConfig();
xAxisBuilder.withDisplay(true).labelConfig().withDisplay(true).withLabelString("days");
xAxisBuilder.tickConfig().withForcedMinimum(smallestXValue);
xAxisBuilder.timeConfig().withTimeUnit(ChartJsTimeUnit.DAY).withStepSize(7);

SimpleChartJsLinearAxisConfigBuilder yAxisBuilder =
	optionsBuilder.scalesConfig().withLinearYAxisConfig();
yAxisBuilder.withDisplay(true)
	.labelConfig()
		.withDisplay(true)
		.withLabelString("active users");
	
String chartJsConfigAsJson = ChartJsObjectMapperFactory.getObjectMapper(true).writeValueAsString(config.build());

In HTML/Javascript

var ctx = document.getElementById('graphPanel').getContext('2d');
new Chart(ctx, chartJsConfigAsJson);

If you use Wicket, you can go straight from building the config to displaying it in the provided SimpleGraphPanel:

public GraphPage()
{
	add(new SimpleGraphPanel("graphPanel", getChartJsConfigModel(), Model.of("My graph")));
}

See the tests of the java-chartjs-wicket module for more examples.

Maven Central

Java-chartjs is available from Maven Central. Simply add the relevant artifacts to your dependencies.

<dependency>
	<groupId>nl.crashdata.java-chartjs</groupId>
	<artifactId>java-chartjs-data</artifactId>
	<version>1.0.0</version>
</dependency>

java-chartjs-data contains a set of POJOs annotated with Jackson annotations for easy serialization. It also contains a set of builders to help in creating a full ChartJsConfig.

java-chartjs-serialization contains helper code for easy serialization of config based on java-chartjs-data classes to a JSON config object for chartjs.

java-chartjs-wicket contains a simple wicket SimpleGraphPanel, as well as up-to-date ChartJs and moment.js libraries and assorted ResourceReferences.

ChartJs versions

java-chartjs Chart.js moment.js
2.1.x 2.9.3 2.27.0
2.0.x 2.8.0 2.24.0
1.0.0 2.8.0 2.24.0
0.9x 2.7.2 2.22.2
0.80 2.7.2 2.21.0
0.70 2.7.2 2.21.0

Versions

Version
0.50
0.13
0.12
0.11
0.10
0.9
0.7