|
1 |
| -# Lets-Plot for Kotlin Developers Guide |
| 1 | +# Lets-Plot for Kotlin Developers Guide |
2 | 2 |
|
3 | 3 | ### Building the project
|
4 | 4 |
|
5 |
| -Copy file `build_settings.template.yml` located in the project root directory to the file named `build_settings.yml` in the same location. |
| 5 | +Copy file `build_settings.template.yml` located in the project root directory to the file named `build_settings.yml` in |
| 6 | +the same location. |
6 | 7 |
|
7 | 8 | run `./gradlew build`
|
8 | 9 |
|
9 | 10 | ### Running demos
|
10 | 11 |
|
11 |
| -Aside from examples of Jupyter notebooks the project also contains a set of simple demos showing how plots can be built outside Jupyter notebook environment. Each such demo has `main` method and is launched like any other simple JVM application. |
| 12 | +Aside from of Jupyter demo notebooks the project also contains a set of simple demos showing how plots can be built in a |
| 13 | +JVM or Kotlin-JS environment. |
| 14 | + |
| 15 | +Each JVM demo has `main` method and is launched like any other JVM application. |
| 16 | + |
| 17 | +The Kotlin-JS demo app is launched using Gradle task: `./gradlew :js-frontend-app:browserDevelopmentRun` |
| 18 | + |
| 19 | +The simple demos can be found in the following folders: |
12 | 20 |
|
13 |
| -The simple demos can be found in the following folders: |
14 | 21 | ```
|
15 | 22 | lets-plot-kotlin/demo/browser
|
16 | 23 | lets-plot-kotlin/demo/jvm-batik
|
17 | 24 | lets-plot-kotlin/demo/jvm-javafx
|
| 25 | +lets-plot-kotlin/demo/geotools-batik |
| 26 | +lets-plot-kotlin/demo/js-frontend-app |
18 | 27 | ```
|
19 | 28 |
|
20 |
| -### Creating plots in JVM-based applications |
| 29 | +### Lets-Plot in JVM and Kotlin-JS applications |
21 | 30 |
|
22 |
| -Lets-Plot library enables embedding plots into a JVM-based application. |
| 31 | +Lets-Plot library enables embedding plots into a JVM or Kotlin-JS application. |
23 | 32 |
|
24 |
| -It also offers a choice between [JavaFX](https://en.wikipedia.org/wiki/JavaFX) graphics and rendering powered by [Apache Batik SVG Toolkit](https://xmlgraphics.apache.org/batik/). |
| 33 | +When in JVM environment the Lets-Plot library offers a choice between [JavaFX](https://en.wikipedia.org/wiki/JavaFX) |
| 34 | +graphics and rendering powered by [Apache Batik SVG Toolkit](https://xmlgraphics.apache.org/batik/). |
25 | 35 |
|
26 |
| -#### Required Maven artifacts published by the main [Lets-Plot](https://github.com/JetBrains/lets-plot) project |
| 36 | +#### Artifacts |
27 | 37 |
|
28 |
| -- `lets-plot-common` |
29 |
| -- `lets-plot-batik` or `lets-plot-jfx` (choose one) |
| 38 | +All artifacts are available at [Maven Central](https://search.maven.org/search?q=lets-plot). |
30 | 39 |
|
31 |
| -[](https://search.maven.org/search?q=lets-plot) |
| 40 | +<table> |
| 41 | + <tr> |
| 42 | + <td>Lets-Plot Kotlin API</td> |
| 43 | + <td> |
| 44 | + <i>lets-plot-kotlin-jvm</i><br> |
| 45 | + <i>lets-plot-kotlin-js</i><br> |
| 46 | + <i>lets-plot-kotlin-geotools</i> |
| 47 | + </td> |
| 48 | + <td> |
| 49 | + <a href="https://search.maven.org/search?q=lets-plot"/> |
| 50 | + <img src="https://img.shields.io/maven-central/v/org.jetbrains.lets-plot/lets-plot-kotlin?color=blue&label=Maven%20Central"/> |
| 51 | + </td> |
| 52 | + <td> |
| 53 | + Published by this project. |
| 54 | + </td> |
| 55 | + </tr> |
| 56 | + <tr> |
| 57 | + <td>Lets-Plot library</td> |
| 58 | + <td> |
| 59 | + <i>lets-plot-batik</i><br> |
| 60 | + <i>lets-plot-jfx</i><br> |
| 61 | + <i>lets-plot-common</i> |
| 62 | + </td> |
| 63 | + <td> |
| 64 | + <a href="https://search.maven.org/search?q=lets-plot"/> |
| 65 | + <img src="https://img.shields.io/maven-central/v/org.jetbrains.lets-plot/lets-plot-common?color=blue&label=Maven%20Central"/> |
| 66 | + </td> |
| 67 | + <td> |
| 68 | + Published by the <a href="https://github.com/JetBrains/lets-plot">Lets-Plot library</a> project. |
| 69 | + </td> |
| 70 | + </tr> |
| 71 | +</table> |
32 | 72 |
|
33 |
| -#### Lets-Plot Kotlin API artifact (published by this project) |
| 73 | +#### Project dependencies |
34 | 74 |
|
35 |
| -- `lets-plot-kotlin-api` |
| 75 | +The following is how you configure a Gradle (Groovy) project: |
36 | 76 |
|
37 |
| -[](https://search.maven.org/search?q=lets-plot-kotlin) |
| 77 | +```groovy |
| 78 | +repositories { |
| 79 | + mavenCentral() |
| 80 | +} |
| 81 | +``` |
38 | 82 |
|
39 |
| -#### Project dependencies |
| 83 | +- JVM/Swing/Batik application: |
40 | 84 |
|
41 |
| -All artifacts are available at [Maven Central](https://search.maven.org/search?q=lets-plot). |
| 85 | +```groovy |
| 86 | +dependencies { |
| 87 | + implementation "org.jetbrains.lets-plot:lets-plot-batik:$lets_plot_library_version>" |
| 88 | + implementation "org.jetbrains.lets-plot:lets-plot-kotlin-jvm:$lets_plot_kotlin_api_version" |
| 89 | +} |
| 90 | +``` |
42 | 91 |
|
43 |
| -The following is an example fragment of a Gradle project that uses Lets-Plot Kotlin API and Apache Batik rendering: |
| 92 | +- JVM/Swing/JavaFX application: |
44 | 93 |
|
45 | 94 | ```groovy
|
46 | 95 | dependencies {
|
47 |
| - implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8" |
48 |
| - implementation "org.jetbrains.lets-plot:lets-plot-batik:<lib version>" |
49 |
| - api "org.jetbrains.lets-plot:lets-plot-common:<lib version>" |
50 |
| - api "org.jetbrains.lets-plot:lets-plot-kotlin-api:<api version>" |
| 96 | + implementation "org.jetbrains.lets-plot:lets-plot-jfx:$lets_plot_library_version" |
| 97 | + implementation "org.jetbrains.lets-plot:lets-plot-kotlin-jvm:$lets_plot_kotlin_api_version" |
51 | 98 | }
|
52 | 99 | ```
|
53 | 100 |
|
| 101 | +- Kotlin-JS application: |
| 102 | + |
54 | 103 | ```groovy
|
55 |
| -repositories { |
56 |
| - mavenCentral() |
| 104 | +dependencies { |
| 105 | + implementation "org.jetbrains.lets-plot:lets-plot-kotlin-js:$lets_plot_kotlin_api_version" |
57 | 106 | }
|
58 | 107 | ```
|
59 | 108 |
|
60 |
| -#### An example of a **minimal JVM-based** application |
| 109 | +#### Example applications |
| 110 | + |
| 111 | +The [lets-plot-mini-apps](https://github.com/alshan/lets-plot-mini-apps) GitHub repository contains examples of using |
| 112 | +the Lets-Plot Kotlin API in JVM and Kotlin-JS projects. |
| 113 | + |
| 114 | +You will also find similar "minimal" apps in this repository. |
61 | 115 |
|
62 |
| -- Using Apache Batik: |
63 |
| - [minimalDemo/Main.kt](https://github.com/JetBrains/lets-plot-kotlin/blob/master/demo/jvm-batik/src/main/kotlin/minimalDemo/Main.kt) |
| 116 | +- JVM/Swing/Apache Batik: |
| 117 | + [minimalDemo/Main.kt](https://github.com/JetBrains/lets-plot-kotlin/blob/master/demo/jvm-batik/src/main/kotlin/minimalDemo/Main.kt) |
64 | 118 |
|
65 |
| -- Using JavaFX: |
66 |
| - [minimalDemo/Main.kt](https://github.com/JetBrains/lets-plot-kotlin/blob/master/demo/jvm-javafx/src/main/kotlin/minimalDemo/Main.kt) |
| 119 | +- JVM/Swing/JavaFX Scene: |
| 120 | + [minimalDemo/Main.kt](https://github.com/JetBrains/lets-plot-kotlin/blob/master/demo/jvm-javafx/src/main/kotlin/minimalDemo/Main.kt) |
67 | 121 |
|
| 122 | +- Kotlin-JS: |
| 123 | + [js-frontend-app](https://github.com/JetBrains/lets-plot-kotlin/tree/master/demo/js-frontend-app) |
68 | 124 |
|
69 | 125 | ### Frontend context
|
70 | 126 |
|
71 |
| -`Frontend context` is required for method `show()` in `Figure` interface to work properly. Both `Plot` and `GGBunch` classes in `Lets-Plot` Kotlin API implement `Figure` interface. |
72 |
| -Calling method `show` is typical for interactive notebook-like applications. |
| 127 | +`Frontend context` is required for method `show()` in `Figure` interface to work properly. Both `Plot` and `GGBunch` |
| 128 | +classes in `Lets-Plot` Kotlin API implement `Figure` interface. Calling method `show` is typical for interactive |
| 129 | +notebook-like applications. |
73 | 130 |
|
74 | 131 | The following steps describe how to use `Lets-Plot` JVM "backend" in "browser" frontend context.
|
75 | 132 |
|
|
0 commit comments