Chartjs-ZK

Chartjs ZK integration library

License

License

Categories

Categories

JavaScript Languages
GroupId

GroupId

tools.dynamia.zk.addons
ArtifactId

ArtifactId

chartjs-zk
Last Version

Last Version

2.7.3
Release Date

Release Date

Type

Type

jar
Description

Description

Chartjs-ZK
Chartjs ZK integration library
Project Organization

Project Organization

Dynamia Soluciones IT
Source Code Management

Source Code Management

https://github.com/dynamia-projects/chartjs-zk

Download chartjs-zk

How to add to project

<!-- https://jarcasting.com/artifacts/tools.dynamia.zk.addons/chartjs-zk/ -->
<dependency>
    <groupId>tools.dynamia.zk.addons</groupId>
    <artifactId>chartjs-zk</artifactId>
    <version>2.7.3</version>
</dependency>
// https://jarcasting.com/artifacts/tools.dynamia.zk.addons/chartjs-zk/
implementation 'tools.dynamia.zk.addons:chartjs-zk:2.7.3'
// https://jarcasting.com/artifacts/tools.dynamia.zk.addons/chartjs-zk/
implementation ("tools.dynamia.zk.addons:chartjs-zk:2.7.3")
'tools.dynamia.zk.addons:chartjs-zk:jar:2.7.3'
<dependency org="tools.dynamia.zk.addons" name="chartjs-zk" rev="2.7.3">
  <artifact name="chartjs-zk" type="jar" />
</dependency>
@Grapes(
@Grab(group='tools.dynamia.zk.addons', module='chartjs-zk', version='2.7.3')
)
libraryDependencies += "tools.dynamia.zk.addons" % "chartjs-zk" % "2.7.3"
[tools.dynamia.zk.addons/chartjs-zk "2.7.3"]

Dependencies

provided (2)

Group / Artifact Type Version
org.zkoss.zk : zk jar 8.5.0
org.zkoss.zk : zul jar 8.5.0

test (1)

Group / Artifact Type Version
junit : junit jar 4.12

Project Modules

There are no modules declared in this project.

Maven Central

Chart.js for ZK

This library let you use Chart.js v2.7.3 (https://github.com/chartjs/Chart.js) framework in ZK application using pure Java or ZUL.

Current Version: 2.7.3

Demo

Please play with the demo to learn how to use the new api and all charts types.

Bulding

This is a regular maven project, download and build it using the following command:

mvn clean install

Installation

Just add chartjs-zk-xx.jar to your project dependencies:

Maven

<dependency>
    <groupId>tools.dynamia.zk.addons</groupId>
    <artifactId>chartjs-zk</artifactId>
    <version>2.7.3</version>
</dependency>

Gradle

compile "tools.dynamia.zk.addons:chartjs-zk:2.7.3"

Usage

From zul

<chartjs type="pie" title="My Charts" data="@bind(vm.chartData)"/>
public class PieChartViewModel{
    
    public ChartjsData getChartData(){
        CategoryChartjsData chartData = new CategoryChartjsData();
        chartData.add("2014", 1030);
        chartData.add("2015", 200);
        chartData.add("2016", 3500);
        return chartData;
    }
}

From java

import tools.dynamia.chartjs.*;
import org.zkoss.zul.*

public class PieChart{

    public void init(){
        Chartjs chart = new Chartjs();
        chart.setType(Chartjs.TYPE_PIE);
        chart.setTitle("My Chartjs");
        chart.setData(getChartData());
        
        Window window = new Window();
        window.appendChild(chart);
        window.doModal();
        
    }
    
    public ChartjsData getChartData(){
        CategoryChartjsData chartData = new CategoryChartjsData();
        chartData.add("2014", 1030);
        chartData.add("2015", 200);
        chartData.add("2016", 3500);
        return chartData;
    }
}

ChartjsData class follow the same model as chartjs JSON data but with helper methods. See Chartjs documentation http://www.chartjs.org/docs/

Supported Chart Types

  • bar
  • horizontalBar
  • line
  • pie
  • scatter
  • doughnut
  • radar
  • polarArea
  • bubble

Fluent API

        CategoryChartjsData data = new CategoryChartjsData();
        data.add("A", 11.1);
        data.add("B", 22.2);
        data.add("C", 33.3);
        data.add("D", 44.4);
        data.setDatasetLabel("The DataSet");

        Chartjs chart = new Chartjs(Chartjs.TYPE_BAR);
        chart.setData(data);
        chart.setOptions(
                ChartjsOptions.Builder.init()
                        .scales(new Scales()
                                .addY(Axe.Builder.init()
                                        .scaleLabel(ScaleLabel.Builder.init()
                                                .labelString("ChartJs For ZK")
                                                .display(true)
                                                .build()) // scale label
                                        .ticks(Ticks.Builder.init()
                                                .min(0)
                                                .max(100)
                                                .build()) // ticks
                                        .build())) //Axe
                        .build() // options
        );
        chart.setWidth("100%");
        chart.setParent(parent);

What's New ?

v2.7.2_R1

  • Upgrade to Chartjs 2.7.2
  • New Java API for all configurations parameters in ChartjsOptions
  • Dataset now can use Scales (axis) from Java
  • Dataset has all chartjs properties
  • Builders for POJO Classes (fluent api)
  • New versioning system. First 3 numbers means the Chart.js version used. Identifier _R1 means the release number of this project.
  • New GroupId tools.dynamia.zk.addons. We start developing new addons for zk
  • Fixes and clean code
  • Basic Demo

v2.7.3

  • Upgrade to Chartjs 2.7.3

License

Chartjs-ZK is available under the Apache 2 License.

Want contribute?

Please read Contributing Guidelines

tools.dynamia.zk.addons

Dynamia Projects

Dynamia open source projects

Versions

Version
2.7.3
2.7.2_R1