An Android, JavaFx, JS multiplatform datavisualization library with comprehensive DSL

Overview

Data2viz

Build Status GitHub License

Build JS Build JS Build JS Build JS

Isomorphic dataviz

Data2viz is a data visualization toolbox for Kotlin Multiplatform.

You can pick what you need in the different modules and use them independently in the following environments: Android, JavaScript(IR and Legacy), and JavaFX (iOs to come).

Your code produces the same results and rendering on each platform.

A lot of algorithms come from d3js modules.

core

This module exposes some basics elements like Circle, Rect, Path, and also some parts of DSL (percent, angles, etc.).

color

This module provides algorithms to create, modify, and convert colors through differents spaces (RGB, HCL, HSL, Lab). It also manage linear and radial color gradients. You can easily use it outside of data2viz.

shape

Algorithms to generate paths: symbols, curves, ...

scale

Different ways to convert data to sizes.

interpolate

Functions to perform interpolation of various elements (numbers, colors, points, curves)

random

Algorithms to generate random data.

axis

Helper module to create axis for charts, using scales.

delaunay

This module is a high performant algorithm to compute the Voronoi diagram. You should use it in many use cases to find the closest point of interest to the pointer position.

ease

This module contains a collection of easing functions to manage acceleration inside animations.

dsv

Minimal way of parsing CSV, TSV files using Kotlin.

force

Use physics to animate your visualizations.

format

Different ways of formating numbers and currencies.

time

Some multiplatform classes to manage time and dates in visualizations.

time-format

Extend formatting to time and dates.

quadtree

Separation of space through the quadtree algorithm.

voronoi

Fortune's algorithm implementation of the Voronoi diagram. You should probably use Delaunay instead.

geo

A collection of mechanisms and functions to project GeoJson elements (points, lines, polygons) on a screen using different implementations of projections.

hexbin

A useful way of aggregating data using hexagons. You can represent data through the fill color or the area.

sankey

A generator for sankey charts.

hierarchy

A generator for hierarchical charts.

tests

An internal module used to simplify multiplatform testing with a higher DSL.

timer

A multiplatform implementation to manage animations through shared frames.

viz

Multiplatorm API and implementation of rendering and events management.

Data2viz allows you to develop data visualizations through a fully typed DSL. It simplifies the creation of complex visualizations via the IDE’s context-based suggestions.

Where should I start?

Documentation

All data2viz documentation is located in a distinct documentation project. You should start there and follow the first JavaFX tutorial.

Data2viz Playground

You can also play with the API without installing anything. Data2viz playground is a website where you can browse existing sample, modify them online and immediately see the result.

Using in your projects

Note that the library is experimental, and the API is subject to change.

The library is published to data2viz space repository.

Gradle

  • Add the data2viz maven repository:
repositories {
    maven { url = uri("https://maven.pkg.jetbrains.space/data2viz/p/maven/public") }
}
  • In multiplatform projects, add a dependency to the commonMain source set dependencies
kotlin {
    sourceSets {
        commonMain {
             dependencies {
                 implementation("io.data2viz.d2v:axis:0.8.17")
                 implementation("io.data2viz.d2v:chord:0.8.17")
                 implementation("io.data2viz.d2v:color:0.8.17")
                 implementation("io.data2viz.d2v:contour:0.8.17")
                 implementation("io.data2viz.d2v:delaunay:0.8.17")
                 implementation("io.data2viz.d2v:dsv:0.8.17")
                 implementation("io.data2viz.d2v:ease:0.8.17")
                 implementation("io.data2viz.d2v:force:0.8.17")
                 implementation("io.data2viz.d2v:format:0.8.17")
                 implementation("io.data2viz.d2v:geo:0.8.17")
                 implementation("io.data2viz.d2v:hexbin:0.8.17")
                 implementation("io.data2viz.d2v:hierarchy:0.8.17")
                 implementation("io.data2viz.d2v:quadtree:0.8.17")
                 implementation("io.data2viz.d2v:random:0.8.17")
                 implementation("io.data2viz.d2v:scale:0.8.17")
                 implementation("io.data2viz.d2v:shape:0.8.17")
                 implementation("io.data2viz.d2v:tile:0.8.17")
                 implementation("io.data2viz.d2v:time:0.8.17")
                 implementation("io.data2viz.d2v:timer:0.8.17")
                 implementation("io.data2viz.d2v:viz:0.8.17")
             }
        }
    }
}
  • To use the library in a single-platform project, add a dependency to the dependencies block.
dependencies {
    implementation("io.data2viz.d2v:axis:0.8.17")
    implementation("io.data2viz.d2v:chord:0.8.17")
    implementation("io.data2viz.d2v:color:0.8.17")
    implementation("io.data2viz.d2v:contour:0.8.17")
    implementation("io.data2viz.d2v:delaunay:0.8.17")
    implementation("io.data2viz.d2v:dsv:0.8.17")
    implementation("io.data2viz.d2v:ease:0.8.17")
    implementation("io.data2viz.d2v:force:0.8.17")
    implementation("io.data2viz.d2v:format:0.8.17")
    implementation("io.data2viz.d2v:geo:0.8.17")
    implementation("io.data2viz.d2v:hexbin:0.8.17")
    implementation("io.data2viz.d2v:hierarchy:0.8.17")
    implementation("io.data2viz.d2v:quadtree:0.8.17")
    implementation("io.data2viz.d2v:random:0.8.17")
    implementation("io.data2viz.d2v:scale:0.8.17")
    implementation("io.data2viz.d2v:shape:0.8.17")
    implementation("io.data2viz.d2v:tile:0.8.17")
    implementation("io.data2viz.d2v:time:0.8.17")
    implementation("io.data2viz.d2v:timer:0.8.17")
    implementation("io.data2viz.d2v:viz:0.8.17")
}

Current status and roadmap

APIs are mostly stabilized now, but there may still be some breaking changes before v1.0.

Inspirations

  • d3js: a lot of modules and algorithms come from d3js.
  • paperjs: another source of inspiration for viz hierarchy and simple API.
  • chromajs: smart library for managing colors easily.
  • delaunator: a really fast JavaScript library for Delaunay triangulation of 2D points.
  • kotlinx.html: isomorphic html rendering.
  • kotlintest: nice DSL for testing (partly ported in test).
Comments
  • [feat] Svg export

    [feat] Svg export

    As discussed https://github.com/data2viz/data2viz/issues/239, this adds Viz.toSVG() support.

    Support is almost finished, almost everything works. What still needs to be done:

    • Gradients need more tests (especially radial)
    • More tests in general
    • Text is a bit misaligned (too far downwards)
    • Chart<*>.toSVG()

    If there are any suggestions for tests or text alignment, let me know!

    opened by Jolanrensen 10
  • Travis multi-platform build

    Travis multi-platform build

    This is a potential solution for #29.

    I updated the Travis config to use a build matrix in order to be able to run the default build and android build in parallel. You can view the build here, which has one regular Java job and one Android job.

    The main Java job runs exactly the same as before. The android job disables the "-js" sub-projects to avoid duplicate work. I tried also disabling "-jfx" projects as these seemed unnecessary, but I discovered that some of the "-jvm" projects depend on "-jfx" ones. I added the toggle for js and jfx using boolean properties in gradle.properties files, which can be overridden using project properties, for example: ./gradlew -Dinclude_js=false check. Some checks were added in settings.gradle for these properties.

    I had to update the android sdk to version 28 in the root project, as examples/app and viz/rendering-app both were already on 28 and it's way easier to have everything on the same version for Travis.

    I also removed local.properties from git and added an exclusion to .gitignore.

    Let me know if you have any feedback!

    opened by erikthered 7
  • Handling changing and/or real-time data

    Handling changing and/or real-time data

    I would like to be able to update visualizations without entirely recreating them, and possibly do that for real-time (rapidly updating) data.

    As far as I can tell, this is not very feasible with the current API - on Android (which is the platform I am working with) it seems that to update a visualization, you have to remove the old View and replace it with a new one, which is a pretty wasteful way of updating graphs.

    Have I missed something here? If not, is there a chance that this will be implemented at some point, or should I turn to specialized real-time libraries for that?

    opened by Namnodorel 4
  • Make travis works with android, JavaFx, and Js

    Make travis works with android, JavaFx, and Js

    Travis CI fails on android configuration:

    * What went wrong:
    A problem occurred evaluating project ':app'.
    > The SDK directory '/Users/gaetan/Library/Android/sdk' does not exist.
    

    See https://stackoverflow.com/questions/27644586/how-to-set-up-travis-ci-with-multiple-languages and https://docs.travis-ci.com/user/languages/android/

    help wanted 
    opened by gzoritchak 4
  • Naming conventions

    Naming conventions

    Why of all the class and singleton names these particular ones should start with a lowercase letter?

    scales.continuous.linear { }

    instead of

    Scales.Continuous.linear { }

    This strikes me as a very odd and arbitrary decision.

    toBeDiscussed API 
    opened by yay 4
  • Simple Network Graph example

    Simple Network Graph example

    Hi I tried to rewrite a simple d3js network graph http://bl.ocks.org/jose187/4733747 to data2viz. I'm using the ex-force example as reference.

    But i'm stuck. Since i'm still unfamiliar with the DSL & the API. Could you give me some pointer or the classes to use to rewrite this. Thanks.

    question 
    opened by abangkis 3
  • Implement all rendering tests of Path.arc

    Implement all rendering tests of Path.arc

    Due to the differences in arc API on each platform, all cases should be tested on all platforms with a comparison of the rendered images.

    start; end; counterclocwise; 0; 0.25PI; false 0; 0.25PI; true 0; 2.0PI; true 0; 2.0PI; false .25PI; 2.25PI; true .25PI; 2.25PI; false ...

    bug 
    opened by gzoritchak 3
  • data2viz js not working in IExplorer - (append?)

    data2viz js not working in IExplorer - (append?)

    I got a graph to work in Chrome, Firefox, Edge, but not in Iexplorer. I can see the online JS examples are also not working in IExplorer.

    I think it may be because IExplorer does not accept the append method on dom elements, these calls could be probably replaced with "appendChild".

    opened by palfred 3
  • Examples from README not working

    Examples from README not working

    The README of your repository contains two links to examples: http://data2viz.io/dist/chart.html http://data2viz.io/dist/svgperfs.html both are not working for me neither in Firefox nor in Chrome.

    opened by jonek 3
  • chart in loop ?

    chart in loop ?

    was searching for a while but never found any helpful topic on how to express continuous and streamed data in moving graph to generalize assume

    var x = 0
    while(true){
       x++
       // displaying x in continuous manner
    }
    

    tried approach that behaves almost exactly like the code below

    val p = Pane()
                                var x = 1.0
                                val viz = p.newVizContainer().apply {
                                    size = Size(width, height)
                                }
                                while(true) {
                                    x++
                                    values[1] = x
    
                                    print(values)
    
    
    
                                    //  while(true) {
                                    viz.chart(values) {
                                        val values = quantitative({ domain })
    
                                        plot(values, values)
                                    }
                                    //  }
    
                                    val scene = Scene(p, width, height)
                                    jfxpanel.scene = scene
                  }
    

    but never succeed

    opened by Reqeique 2
  • chore(deps): bump fstream from 1.0.11 to 1.0.12 in /d2v-axis/d2v-axis-js

    chore(deps): bump fstream from 1.0.11 to 1.0.12 in /d2v-axis/d2v-axis-js

    Bumps fstream from 1.0.11 to 1.0.12.

    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot ignore this [patch|minor|major] version will close this PR and stop Dependabot creating any more for this minor/major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language

    You can disable automated security fix PRs for this repo from the Security Alerts page.

    dependencies 
    opened by dependabot[bot] 2
  • Scaling transformation is missing

    Scaling transformation is missing

    opened by JoonasC 0
  • Force Directed Graphs

    Force Directed Graphs

    Hey there,

    does this library also support force directed graphs for multiplatform targets, specifically jetbrains compose multiplatform? i've seen this demo but it looks like its only for kotlin/js

    opened by rbbl-dev 0
  • Android: Handle view size/measurements better

    Android: Handle view size/measurements better

    Currently, the Android implementation of D2V doesn't handle the size of the viz particularly well.

    • the VizContainerView has a default size of 100x100, which gets replaced by the size given by the system in onSizeChanged(). If container.newViz() gets called before the size has been updated, the viz will only receive the default square size to work with.
    • when the size of the container gets updated, it also updates the size of the viz but doesn't call viz.resize(), which means that the viz can't respond to the update.
    • there is no way for the viz to modify the container size. On Android, a view can actually have a width/height of wrap_content, which means that the viz can choose itself what size it wants to have. However, this was not something I was able to make use of with the current API.

    I'm currently using this workaround to make sure the viz always receives the correct container size (using Compose, but the idea should be independent of it):

    AndroidView(
            factory = { context ->
                val container = VizContainerView(context)
    
                val viz = container.newViz {}
    
                // Draw viz when the size given by the outside changes
                container.addResizeListener {
                    viz.clear()
                    viz.apply { ... }
                    // Start the animations, D2V doesn't launch them by itself.
                    viz.startAnimations()
                }
    
                return@AndroidView container
            },
            // Modifiers determining the size of the view
        )
    

    I'm not sure what changes exactly would need to be made, but as it is, I found it a frustrating experience to simply figure out how to draw my viz with the correct measurements.

    opened by Namnodorel 2
  • [Feature request] Export as SVG

    [Feature request] Export as SVG

    To use renders and plots in papers it would be very useful to be able to export them to a vector format like SVG. As indicated by the developers, there already exists a small conversion to SVG for geoms: https://github.com/data2viz/data2viz/blob/33d381fb6349877c9cafe084cb69c3a6f8a86349/core/src/commonMain/kotlin/io/data2viz/geom/PathGeom.kt#L138 but this isn't the case yet for everything that can be rendered. I don't how much work it would be or how easy it would be per-platform.

    If I'm correct, we would need new renderers like for Jfx (https://github.com/data2viz/data2viz/tree/master/viz/src/jfxMain/kotlin/io/data2viz/viz) but then to create an SVG string right?

    opened by Jolanrensen 7
Releases(v0.9.1)
  • v0.9.1(Jan 26, 2022)

  • v0.9.0(Jan 26, 2022)

  • v0.7.1-RC3(Nov 4, 2018)

  • v0.7.0-RC1(Sep 28, 2018)

    This new major release provides android support. It is now possible to create dataviz in common code and deploy them on 3 platforms: android, JS and JFx.

    The mechanism of producing visualizations has changed and now all platforms are base on a memory representations that are rendered to canvas on each platforms.

    Source code(tar.gz)
    Source code(zip)
  • v0.5.0(Mar 16, 2018)

    Geo Module

    This is the big part of this new release. The port of Geo Module from d3js to data2viz in a multiplatform way. The module has a dependency on a external project geojson-kotlin for the serialization of GeoJson. The Geo Module has not all the projections, they will arrive later.

    Timer

    The timer module provides a multiplatform way of managing timers. They allow to create animations from common code. The actual code use then window.requestAnimationFrame in the browser and AnimationTimer inside JFX.

    Bugs and enhancement

    Path implementation in JFX are now using the JFX base Path element and not the SVGPath that had some bugs. First introduction of LinearGradient to be used with fill property of viz elements.

    Source code(tar.gz)
    Source code(zip)
  • v0.3.1(Feb 1, 2018)

  • v0.3.0(Jan 30, 2018)

  • v0.2.6(Dec 1, 2017)

    The first version of the format API wasn't easy to use and remember. It was based on string to specify the formatter options.

    With this new version, we propose a typed version of the API making it easier to use.

    This version also contains 80% of the implementation of the scale module (but with an API that could change).

    Source code(tar.gz)
    Source code(zip)
  • v0.2.5(Nov 22, 2017)

    This new version essentially contains a full multiplatform version of format module. We can now use the same formatting specification for both js and jvm targets.

    It also contains the first commits for the viz module.

    Source code(tar.gz)
    Source code(zip)
  • v0.2.4(Nov 13, 2017)

  • v0.2.3(Nov 13, 2017)

    Applying the modifications provided by this new version of kotlin (implements -> expectedBy).

    • d2v-contour: 30% completed.
    • d2v-shape: 70% completed.
    Source code(tar.gz)
    Source code(zip)
  • v0.2.0(Nov 13, 2017)

    The ultimate goal of this library is to be deployed on various platforms. Since there is still much to do (version 1.0 is not going to be released soon), we decided to move on prereleases of kotlin 1.2. Kotlin 1.2 provides multiplatform as a experimental feature.

    The main benefit is the sharing of code through common modules.

    As a result the structure of the project has completely changed. Every module now exists in a common, a js and a jvm version.

    Source code(tar.gz)
    Source code(zip)
A lightweight, feature-rich wrapper for the Telegram Bot API, providing a handy Kotlin DSL to quickly build your bot.

Kotlin Telegram Bot Kotlin based wrapper over Telegram API. Current version of the Telegram Api: 6.0 Principles Annotations Magic. The basic interacti

Jey 61 Dec 27, 2022
Samples demonstrating the features and use of Koala Plot, a Compose Multiplatform based charting and plotting library written in Kotlin.

Koala Plot Samples This repository houses samples demonstrating the use and features of Koala Plot libraries. How to run Build koalaplot-core with the

Koala Plot 6 Oct 18, 2022
Clean Architecture Kotlin Multiplatform Mobile (KMM) with Android Instrument Test and Unit Test

The-Movies: Clean Architecture Kotlin Multiplatform Mobile What're inside? - Jetpack Compose - Hilt - Ktor - Android Instrument Test - Unit Test - SQL

null 17 Dec 5, 2022
Cody Engel 2 Apr 20, 2022
Mobile client for official Nextcloud News App written as Kotlin Multiplatform Project

Newsout Android and iOS mobile client for Nextcloud news App. The Android client is already available to download in the Play Store. F-Droid and Apple

Simon Schubert 118 Oct 3, 2022
BuildConfiguration information for use in multi-module, or Kotlin Multiplatform common code

component-build-configuration A small library supporting Kotlin Multiplatform for utilizing BuildConfiguration details from common code and across mod

Matthew Nelson 2 Mar 6, 2022
A weather app demo made to play around with Kotlin Multiplatform.

A weather app demo made to play around with Kotlin Multiplatform. Running on Desktop, Ios and Android with all of the business logic being shared across all three platforms!

null 23 Jan 18, 2022
Advent of Code 2021 in Kotlin Multiplatform!

Advent of Code 2021 in Kotlin Multiplatform Structure Each day comes with two parts for you to solve. You'll find a ready-to go and test templates to

Martynas Petuška 2 Dec 6, 2021
A Multiplatform Compose Theme for your Compose app

A Multiplatform Compose Theme for your Compose app

theapache64 45 Oct 5, 2022
Kotlin multiplatform chess backend

chess.kt Kotlin multiplatform chess backend Also contains example of usage as desktop app Usage Create a game Main class that holds all the game state

Vasya Drobushkov 23 Jul 30, 2022
Show worldwide headline. API/Glide library/recycler view/volley library/kotlin/xml/ chrome custom tabs

Show worldwide headline. API/Glide library/recycler view/volley library/kotlin/xml/ chrome custom tabs. -> you can click on headline and it will open an article of that news in the app(no need to go to chrome or any browser)

SUMIT KUMAR 5 Nov 28, 2022
A music picker library for React Native. Provides access to the system's UI for selecting songs from the phone's music library.

Expo Music Picker A music picker library for React Native. Provides access to the system's UI for selecting songs from the phone's music library. Supp

Bartłomiej Klocek 60 Dec 29, 2022
:movie_camera: Movie discovery app showcasing Android best practices with Google's recommended architecture: MVVM + Repository + Offline support + Android Architecture Components + Paging library & Retrofit2.

Popular Movies Stage 1 + Stage 2 Discover the most popular and top rated movies playing. Movies data fetched using themoviedb.org API. ✨ Screenshots M

Yassin AJDI 189 Nov 26, 2022
Oratio Library for Android Studio helps you simplify your Android TTS codes

Oratio Oratio is a library for Android Studio. This library is useful to a number of developers who are currently making apps using android TTS(Text-T

Jacob Lim 1 Oct 28, 2021
Unity-Android-SDK-Plugins - Android SDK/Library/Plugins (aar) for Unity Developers

Unity Android SDK Plugins Unity Android SDK Plugins is an Open Source project th

NNK 1 Aug 14, 2022
Spantastic - an Android library that provides a simple and Kotlin fluent API for creating Android Spannable

Spantastic is an Android library that provides a simple and Kotlin fluent API for creating Android Spannable. This library wrappers SpannableStringBuilder and add methods to easily decorate the text with multiple spans.

Wellington Cabral da Silva 12 Nov 27, 2022
AndroidEssentials is an android library that creates helper functions for performing common tasks in Android

AndroidEssentials is an android library that creates helper functions for performing common tasks in Android such as managing preferences, managing files, showing alerts, showing toasts, checking user country & checking network connection of users. All the methods of the class are static and should be accessed directly from the AndroidEssentials class.

Isaac Sichangi 3 Jul 7, 2022
Utility Android app for generating color palettes of images using the Palette library. Written in Kotlin.

Palette Helper is a simple utility app made to generate color palettes of images using Google's fantastic Palette library. It's mostly a for-fun pet p

Zac Sweers 154 Nov 18, 2022