Skip to content

Commit 7d86f04

Browse files
authoredDec 5, 2024
KTLN-862-Plotting charts in Kotlin with Kandy (#1144)
* Kandy library * Added execution for kotlin-gradle-libraries * Update package
1 parent ee99c9b commit 7d86f04

19 files changed

+2506
-0
lines changed
 
+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
plugins {
2+
kotlin("jvm") version "2.0.20"
3+
}
4+
5+
group = "com.baeldung"
6+
version = "1.0-SNAPSHOT"
7+
8+
repositories {
9+
mavenCentral()
10+
maven("https://packages.jetbrains.team/maven/p/kds/kotlin-ds-maven")
11+
}
12+
13+
dependencies {
14+
implementation("org.jetbrains.kotlinx:kandy-lets-plot:0.7.1")
15+
implementation("org.jetbrains.kotlinx:kotlin-statistics-jvm:0.3.1")
16+
testImplementation("org.assertj:assertj-core:3.6.1")
17+
testImplementation(kotlin("test"))
18+
}
19+
20+
tasks.test {
21+
useJUnitPlatform()
22+
}
23+
kotlin {
24+
jvmToolchain(21)
25+
}
Binary file not shown.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#Sat Nov 23 18:46:55 CET 2024
2+
distributionBase=GRADLE_USER_HOME
3+
distributionPath=wrapper/dists
4+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
5+
zipStoreBase=GRADLE_USER_HOME
6+
zipStorePath=wrapper/dists

‎kotlin-gradle-libraries/gradlew

+234
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,234 @@
1+
#!/bin/sh
2+
3+
#
4+
# Copyright © 2015-2021 the original authors.
5+
#
6+
# Licensed under the Apache License, Version 2.0 (the "License");
7+
# you may not use this file except in compliance with the License.
8+
# You may obtain a copy of the License at
9+
#
10+
# https://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing, software
13+
# distributed under the License is distributed on an "AS IS" BASIS,
14+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
# See the License for the specific language governing permissions and
16+
# limitations under the License.
17+
#
18+
19+
##############################################################################
20+
#
21+
# Gradle start up script for POSIX generated by Gradle.
22+
#
23+
# Important for running:
24+
#
25+
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
26+
# noncompliant, but you have some other compliant shell such as ksh or
27+
# bash, then to run this script, type that shell name before the whole
28+
# command line, like:
29+
#
30+
# ksh Gradle
31+
#
32+
# Busybox and similar reduced shells will NOT work, because this script
33+
# requires all of these POSIX shell features:
34+
# * functions;
35+
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
36+
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
37+
# * compound commands having a testable exit status, especially «case»;
38+
# * various built-in commands including «command», «set», and «ulimit».
39+
#
40+
# Important for patching:
41+
#
42+
# (2) This script targets any POSIX shell, so it avoids extensions provided
43+
# by Bash, Ksh, etc; in particular arrays are avoided.
44+
#
45+
# The "traditional" practice of packing multiple parameters into a
46+
# space-separated string is a well documented source of bugs and security
47+
# problems, so this is (mostly) avoided, by progressively accumulating
48+
# options in "$@", and eventually passing that to Java.
49+
#
50+
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
51+
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
52+
# see the in-line comments for details.
53+
#
54+
# There are tweaks for specific operating systems such as AIX, CygWin,
55+
# Darwin, MinGW, and NonStop.
56+
#
57+
# (3) This script is generated from the Groovy template
58+
# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
59+
# within the Gradle project.
60+
#
61+
# You can find Gradle at https://github.com/gradle/gradle/.
62+
#
63+
##############################################################################
64+
65+
# Attempt to set APP_HOME
66+
67+
# Resolve links: $0 may be a link
68+
app_path=$0
69+
70+
# Need this for daisy-chained symlinks.
71+
while
72+
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
73+
[ -h "$app_path" ]
74+
do
75+
ls=$( ls -ld "$app_path" )
76+
link=${ls#*' -> '}
77+
case $link in #(
78+
/*) app_path=$link ;; #(
79+
*) app_path=$APP_HOME$link ;;
80+
esac
81+
done
82+
83+
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
84+
85+
APP_NAME="Gradle"
86+
APP_BASE_NAME=${0##*/}
87+
88+
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
89+
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
90+
91+
# Use the maximum available, or set MAX_FD != -1 to use that value.
92+
MAX_FD=maximum
93+
94+
warn () {
95+
echo "$*"
96+
} >&2
97+
98+
die () {
99+
echo
100+
echo "$*"
101+
echo
102+
exit 1
103+
} >&2
104+
105+
# OS specific support (must be 'true' or 'false').
106+
cygwin=false
107+
msys=false
108+
darwin=false
109+
nonstop=false
110+
case "$( uname )" in #(
111+
CYGWIN* ) cygwin=true ;; #(
112+
Darwin* ) darwin=true ;; #(
113+
MSYS* | MINGW* ) msys=true ;; #(
114+
NONSTOP* ) nonstop=true ;;
115+
esac
116+
117+
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
118+
119+
120+
# Determine the Java command to use to start the JVM.
121+
if [ -n "$JAVA_HOME" ] ; then
122+
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
123+
# IBM's JDK on AIX uses strange locations for the executables
124+
JAVACMD=$JAVA_HOME/jre/sh/java
125+
else
126+
JAVACMD=$JAVA_HOME/bin/java
127+
fi
128+
if [ ! -x "$JAVACMD" ] ; then
129+
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
130+
131+
Please set the JAVA_HOME variable in your environment to match the
132+
location of your Java installation."
133+
fi
134+
else
135+
JAVACMD=java
136+
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
137+
138+
Please set the JAVA_HOME variable in your environment to match the
139+
location of your Java installation."
140+
fi
141+
142+
# Increase the maximum file descriptors if we can.
143+
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
144+
case $MAX_FD in #(
145+
max*)
146+
MAX_FD=$( ulimit -H -n ) ||
147+
warn "Could not query maximum file descriptor limit"
148+
esac
149+
case $MAX_FD in #(
150+
'' | soft) :;; #(
151+
*)
152+
ulimit -n "$MAX_FD" ||
153+
warn "Could not set maximum file descriptor limit to $MAX_FD"
154+
esac
155+
fi
156+
157+
# Collect all arguments for the java command, stacking in reverse order:
158+
# * args from the command line
159+
# * the main class name
160+
# * -classpath
161+
# * -D...appname settings
162+
# * --module-path (only if needed)
163+
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
164+
165+
# For Cygwin or MSYS, switch paths to Windows format before running java
166+
if "$cygwin" || "$msys" ; then
167+
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
168+
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
169+
170+
JAVACMD=$( cygpath --unix "$JAVACMD" )
171+
172+
# Now convert the arguments - kludge to limit ourselves to /bin/sh
173+
for arg do
174+
if
175+
case $arg in #(
176+
-*) false ;; # don't mess with options #(
177+
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
178+
[ -e "$t" ] ;; #(
179+
*) false ;;
180+
esac
181+
then
182+
arg=$( cygpath --path --ignore --mixed "$arg" )
183+
fi
184+
# Roll the args list around exactly as many times as the number of
185+
# args, so each arg winds up back in the position where it started, but
186+
# possibly modified.
187+
#
188+
# NB: a `for` loop captures its iteration list before it begins, so
189+
# changing the positional parameters here affects neither the number of
190+
# iterations, nor the values presented in `arg`.
191+
shift # remove old arg
192+
set -- "$@" "$arg" # push replacement arg
193+
done
194+
fi
195+
196+
# Collect all arguments for the java command;
197+
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
198+
# shell script including quotes and variable substitutions, so put them in
199+
# double quotes to make sure that they get re-expanded; and
200+
# * put everything else in single quotes, so that it's not re-expanded.
201+
202+
set -- \
203+
"-Dorg.gradle.appname=$APP_BASE_NAME" \
204+
-classpath "$CLASSPATH" \
205+
org.gradle.wrapper.GradleWrapperMain \
206+
"$@"
207+
208+
# Use "xargs" to parse quoted args.
209+
#
210+
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
211+
#
212+
# In Bash we could simply go:
213+
#
214+
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
215+
# set -- "${ARGS[@]}" "$@"
216+
#
217+
# but POSIX shell has neither arrays nor command substitution, so instead we
218+
# post-process each arg (as a line of input to sed) to backslash-escape any
219+
# character that might be a shell metacharacter, then use eval to reverse
220+
# that process (while maintaining the separation between arguments), and wrap
221+
# the whole thing up as a single "set" statement.
222+
#
223+
# This will of course break if any of these variables contains a newline or
224+
# an unmatched quote.
225+
#
226+
227+
eval "set -- $(
228+
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
229+
xargs -n1 |
230+
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
231+
tr '\n' ' '
232+
)" '"$@"'
233+
234+
exec "$JAVACMD" "$@"

‎kotlin-gradle-libraries/gradlew.bat

+89
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
@rem
2+
@rem Copyright 2015 the original author or authors.
3+
@rem
4+
@rem Licensed under the Apache License, Version 2.0 (the "License");
5+
@rem you may not use this file except in compliance with the License.
6+
@rem You may obtain a copy of the License at
7+
@rem
8+
@rem https://www.apache.org/licenses/LICENSE-2.0
9+
@rem
10+
@rem Unless required by applicable law or agreed to in writing, software
11+
@rem distributed under the License is distributed on an "AS IS" BASIS,
12+
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
@rem See the License for the specific language governing permissions and
14+
@rem limitations under the License.
15+
@rem
16+
17+
@if "%DEBUG%" == "" @echo off
18+
@rem ##########################################################################
19+
@rem
20+
@rem Gradle startup script for Windows
21+
@rem
22+
@rem ##########################################################################
23+
24+
@rem Set local scope for the variables with windows NT shell
25+
if "%OS%"=="Windows_NT" setlocal
26+
27+
set DIRNAME=%~dp0
28+
if "%DIRNAME%" == "" set DIRNAME=.
29+
set APP_BASE_NAME=%~n0
30+
set APP_HOME=%DIRNAME%
31+
32+
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
33+
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
34+
35+
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
36+
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
37+
38+
@rem Find java.exe
39+
if defined JAVA_HOME goto findJavaFromJavaHome
40+
41+
set JAVA_EXE=java.exe
42+
%JAVA_EXE% -version >NUL 2>&1
43+
if "%ERRORLEVEL%" == "0" goto execute
44+
45+
echo.
46+
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
47+
echo.
48+
echo Please set the JAVA_HOME variable in your environment to match the
49+
echo location of your Java installation.
50+
51+
goto fail
52+
53+
:findJavaFromJavaHome
54+
set JAVA_HOME=%JAVA_HOME:"=%
55+
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
56+
57+
if exist "%JAVA_EXE%" goto execute
58+
59+
echo.
60+
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
61+
echo.
62+
echo Please set the JAVA_HOME variable in your environment to match the
63+
echo location of your Java installation.
64+
65+
goto fail
66+
67+
:execute
68+
@rem Setup the command line
69+
70+
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
71+
72+
73+
@rem Execute Gradle
74+
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
75+
76+
:end
77+
@rem End local scope for the variables with windows NT shell
78+
if "%ERRORLEVEL%"=="0" goto mainEnd
79+
80+
:fail
81+
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
82+
rem the _cmd.exe /c_ return code!
83+
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
84+
exit /b 1
85+
86+
:mainEnd
87+
if "%OS%"=="Windows_NT" endlocal
88+
89+
:omega
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
plugins {
2+
id("org.gradle.toolchains.foojay-resolver-convention") version "0.8.0"
3+
}
4+
rootProject.name = "kotlin-gradle-libraries"
5+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
package com.baeldung.kandy
2+
3+
import org.jetbrains.kotlinx.dataframe.api.reverse
4+
import org.jetbrains.kotlinx.dataframe.api.toDataFrame
5+
import org.jetbrains.kotlinx.kandy.dsl.plot
6+
import org.jetbrains.kotlinx.kandy.letsplot.export.save
7+
import org.jetbrains.kotlinx.kandy.letsplot.feature.layout
8+
import org.jetbrains.kotlinx.kandy.letsplot.layers.bars
9+
import org.jetbrains.kotlinx.kandy.letsplot.layers.barsH
10+
import org.jetbrains.kotlinx.kandy.letsplot.scales.categoricalColorHue
11+
import org.jetbrains.kotlinx.kandy.util.color.Color
12+
13+
class BarChartPlotter {
14+
val tiobeIndex = mapOf(
15+
"Programming Language" to listOf("Python", "C++", "Java", "C", "C#"),
16+
"Ratings" to listOf(21.90, 11.60, 10.51, 8.38, 5.62)
17+
)
18+
19+
fun plotSimpleBarChart() {
20+
tiobeIndex.plot {
21+
bars {
22+
x("Programming Language")
23+
y("Ratings")
24+
}
25+
}.save("TiobeIndexSimple.png", path = "src/test/resources/charts")
26+
}
27+
28+
fun plotCustomBarChart() {
29+
tiobeIndex
30+
.toDataFrame()
31+
.reverse()
32+
.plot {
33+
barsH {
34+
x("Ratings")
35+
y("Programming Language")
36+
37+
alpha = 0.75
38+
fillColor("Programming Language") {
39+
scale = categoricalColorHue(chroma = 80, luminance = 70)
40+
borderLine.color = Color.BLACK
41+
borderLine.width = 0.5
42+
legend.name = "Programming\n Language"
43+
}
44+
}
45+
layout {
46+
title = "Tiobe Index October 2024"
47+
subtitle = "Top 5 Programming Languages"
48+
caption = "Source: www.tiobe.com"
49+
size = 800 to 600
50+
51+
}
52+
}.save("TiobeIndexCustom.png", path = "src/test/resources/charts")
53+
}
54+
55+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
package com.baeldung.kandy
2+
3+
import org.jetbrains.kotlinx.dataframe.DataFrame
4+
import org.jetbrains.kotlinx.dataframe.io.readCSV
5+
import org.jetbrains.kotlinx.kandy.dsl.categorical
6+
import org.jetbrains.kotlinx.kandy.dsl.plot
7+
import org.jetbrains.kotlinx.kandy.letsplot.export.save
8+
import org.jetbrains.kotlinx.kandy.letsplot.feature.layout
9+
import org.jetbrains.kotlinx.kandy.letsplot.layers.line
10+
import org.jetbrains.kotlinx.kandy.util.color.Color
11+
import org.jetbrains.kotlinx.kandy.util.context.invoke
12+
import org.jetbrains.kotlinx.statistics.kandy.layers.candlestick
13+
14+
class CandlestickChartPlotter {
15+
val bitcoinData = DataFrame.readCSV("src/main/resources/BTC 1y Data.csv", delimiter = ';')
16+
val windowSize = 5
17+
18+
fun plotSimpleCandlestickChart() {
19+
bitcoinData.plot {
20+
candlestick("timestamp", "open", "high", "low", "close")
21+
}.save("BitcoinCandlestickSimple.png", path = "src/test/resources/charts")
22+
}
23+
24+
fun plotCustomCandlestickChart() {
25+
val movingAverages = bitcoinData["close"].toList().map { it as Double }
26+
val movingAverage = DataUtils.calculateMovingAverage(windowSize, movingAverages)
27+
28+
bitcoinData.plot {
29+
candlestick("timestamp", "open", "high", "low", "close") {
30+
x.axis.name = "Date"
31+
alpha(Stat.isIncreased) {
32+
scale = categorical(true to 1.0, false to 0.05)
33+
legend {
34+
name = ""
35+
breaksLabeled(true to "Increase", false to "Decrease")
36+
}
37+
}
38+
fillColor = Color.GREEN
39+
borderLine.color = Color.GREY
40+
}
41+
42+
line {
43+
y(movingAverage)
44+
x("timestamp")
45+
}
46+
47+
layout {
48+
title = "BTC/USD"
49+
size = 800 to 500
50+
}
51+
}.save("BitcoinCandlestickCustom.png", path = "src/test/resources/charts")
52+
}
53+
54+
55+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package com.baeldung.kandy
2+
3+
class DataUtils {
4+
companion object {
5+
fun calculateMovingAverage(windowSize: Int, data: List<Double>): List<Double?> {
6+
val closePrices = data.toList()
7+
8+
return List(closePrices.size) { index ->
9+
if (index < windowSize - 1) null
10+
else {
11+
val window = closePrices.subList(index - windowSize + 1, index + 1)
12+
window.sum() / window.size
13+
}
14+
}
15+
}
16+
}
17+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
package com.baeldung.kandy
2+
3+
import org.jetbrains.kotlinx.dataframe.DataFrame
4+
import org.jetbrains.kotlinx.dataframe.api.filter
5+
import org.jetbrains.kotlinx.dataframe.api.sortBy
6+
import org.jetbrains.kotlinx.dataframe.io.readCSV
7+
import org.jetbrains.kotlinx.kandy.dsl.continuous
8+
import org.jetbrains.kotlinx.kandy.dsl.plot
9+
import org.jetbrains.kotlinx.kandy.letsplot.export.save
10+
import org.jetbrains.kotlinx.kandy.letsplot.feature.layout
11+
import org.jetbrains.kotlinx.kandy.letsplot.layers.points
12+
import org.jetbrains.kotlinx.kandy.letsplot.multiplot.facet.facetWrap
13+
14+
class MultiplotChart {
15+
var bigMacData = DataFrame.readCSV("src/main/resources/BigMac Index.csv")
16+
17+
val sortedBigMacData = bigMacData
18+
.filter { it["name"] in listOf("United States", "Canada", "China", "Euro area") }
19+
.sortBy("name")
20+
21+
fun plotMultiplotChart() {
22+
sortedBigMacData.plot {
23+
points {
24+
x("date") {
25+
axis.name = "Date"
26+
}
27+
y("dollar_price") {
28+
scale = continuous(0.0..8.0)
29+
axis.name = "USD Price"
30+
}
31+
32+
color("name")
33+
size = 2.0
34+
}
35+
36+
facetWrap(nCol = 2) {
37+
facet(bigMacData["name"])
38+
}
39+
layout {
40+
title = "Big Mac Index"
41+
subtitle = "USD Price of a Big Mac in Different Countries"
42+
size = 800 to 600
43+
}
44+
}.save("BigMacData.png", path = "src/test/resources/charts")
45+
}
46+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name;open;high;low;close;volume;marketCap;timestamp
2+
"2781";35044.7899191289;37926.2567969959;34545.8150953191;37054.5201429095;134767494803.38;724074263172.69;"2023-11-06T00:00:00.000Z"
3+
"2781";37070.3058713039;37964.8928323147;34948.5002761446;37386.547774872;143535361088.64;730802775303.56;"2023-11-13T00:00:00.000Z"
4+
"2781";37374.0746847021;38415.3381982376;35670.9718775193;37479.1222936619;130439893957.47;732864171270.83;"2023-11-20T00:00:00.000Z"
5+
"2781";37454.1919552581;40135.6048969089;36750.127104535;39978.3918165449;134360107954.22;781986059221.04;"2023-11-27T00:00:00.000Z"
6+
"2781";39978.6286477951;44705.5150094178;39978.6286477951;43779.6972879957;188503614894.28;856608048216.73;"2023-12-04T00:00:00.000Z"
7+
"2781";43792.0178583651;43808.3730556685;40234.5783345331;41364.665918237;168493481949.39;809628537784.36;"2023-12-11T00:00:00.000Z"
8+
"2781";41348.2020891569;44367.9557717841;40530.2585192877;43016.1176211831;152084171490.39;842253948410.3;"2023-12-18T00:00:00.000Z"
9+
"2781";43010.5729205333;43804.7814175761;41424.0606411494;42265.185654866;157807126206.72;827811209384.42;"2023-12-25T00:00:00.000Z"
10+
"2781";42280.2352761923;45899.7063545898;40813.5348681668;43943.0972289695;202311773985.07;860951836726.3;"2024-01-01T00:00:00.000Z"
11+
"2781";43948.7069553091;48969.3713995297;41724.6137245906;41796.2696064245;259971819745.56;819159863482.62;"2024-01-08T00:00:00.000Z"
12+
"2781";41715.0665274581;43566.2749235186;40297.4578577579;41545.7835143902;139135824834.73;814488966035.62;"2024-01-15T00:00:00.000Z"
13+
"2781";41553.6526912489;42797.1773592875;38521.8938882205;42035.5943721701;155314602893.66;824387868796.11;"2024-01-22T00:00:00.000Z"
14+
"2781";42030.9153796232;43838.9468441061;41818.3310863757;42583.5829201294;135184187434.21;835421763160.27;"2024-01-29T00:00:00.000Z"
15+
"2781";42577.6229811484;48535.9359097846;42264.8172969015;48293.916750573;157826395447.78;947774152969.59;"2024-02-05T00:00:00.000Z"
16+
"2781";48296.3851963696;52820.0669345775;47745.760261073;52122.5454555893;213560041469.69;1023243073518.32;"2024-02-12T00:00:00.000Z"
17+
"2781";52134.8122142975;52945.0525658512;50561.7758617907;51733.2366017007;160769145625.15;1015926591604.23;"2024-02-19T00:00:00.000Z"
18+
"2781";51730.5397930603;63913.1318135774;50931.0316078668;63167.3703575333;322895666088.51;1240856664934.87;"2024-02-26T00:00:00.000Z"
19+
"2781";63137.0046815427;70083.0516244158;59323.9089421326;69019.7863638058;405709693297.48;1356284493147.36;"2024-03-04T00:00:00.000Z"
20+
"2781";69020.5497746578;73750.07385038;64545.3181028634;68390.6228032209;405957750577.11;1343978205472.65;"2024-03-11T00:00:00.000Z"
21+
"2781";68371.3072649579;68897.1344141915;60807.785959948;67234.1723529876;328097121682.69;1322058484488.52;"2024-03-18T00:00:00.000Z"
22+
"2781";67234.0975756782;71727.6837626186;66414.8322302473;71333.6479258644;216324625835.62;1403108244335.61;"2024-03-25T00:00:00.000Z"
23+
"2781";71333.4847168797;71342.0914544441;64559.8999476563;69362.5512776015;229427260104.16;1364795785582.02;"2024-04-01T00:00:00.000Z"
24+
"2781";69362.5540045166;72715.3596085505;60919.10616167;65738.723886878;288243675431.56;1293922154520.65;"2024-04-08T00:00:00.000Z"
25+
"2781";65739.6445392053;66878.6469049673;59651.3902645616;64926.643211728;257889555863.56;1278296008665.19;"2024-04-15T00:00:00.000Z"
26+
"2781";64935.6331696056;67233.9570363906;62424.7206816789;63113.2316825626;176031088174.54;1242661116273.87;"2024-04-22T00:00:00.000Z"
27+
"2781";63106.3642006694;64703.332363219;56555.2940546252;64031.1328085695;217717011806.09;1261203911121.78;"2024-04-29T00:00:00.000Z"
28+
"2781";64038.3135554184;65494.9017248;60208.7815474421;61448.3946717975;161617857128.39;1210435745366.84;"2024-05-06T00:00:00.000Z"
29+
"2781";61451.2185129853;67694.2987797957;60769.8406689419;66278.3700820502;191456349027.25;1305732230286.08;"2024-05-13T00:00:00.000Z"
30+
"2781";66278.7446711611;71946.462688481;66086.1741180514;68518.089965076;225779718034.34;1349968658779.99;"2024-05-20T00:00:00.000Z"
31+
"2781";68512.1802655161;70597.8795113327;66633.4183418303;67751.6025754618;170949409909.92;1335227914032.14;"2024-05-27T00:00:00.000Z"
32+
"2781";67753.8954139676;71907.8489829092;67589.8364154256;69647.9930028748;187569500742.38;1372773642949.49;"2024-06-03T00:00:00.000Z"
33+
"2781";69644.3127359651;70146.068326324;65056.8930142447;66639.0465356994;175973271621.27;1313672583954.16;"2024-06-10T00:00:00.000Z"
34+
"2781";66636.5154989442;67188.3174738561;63180.7982064002;63180.7982064002;163449015388.04;1245656822237.84;"2024-06-17T00:00:00.000Z"
35+
"2781";63173.3527128475;63292.5271566001;58601.7000722967;62678.292079457;195982960749.43;1235944779945.39;"2024-06-24T00:00:00.000Z"
36+
"2781";62673.6063386528;63777.227541783;53717.3754334207;55849.1106386094;213107531442.73;1101324021018.89;"2024-07-01T00:00:00.000Z"
37+
"2781";55849.5737694153;61329.5291439691;54321.0190639668;60787.7923701369;187407019961.57;1198755021571.63;"2024-07-08T00:00:00.000Z"
38+
"2781";60815.4578978154;68372.9051655897;60704.9291986666;68154.522905866;222161876178.07;1344591292880.38;"2024-07-15T00:00:00.000Z"
39+
"2781";68152.9761329417;69398.5113084796;63473.4732846473;68255.8657690205;227265184991.35;1346858598263.74;"2024-07-22T00:00:00.000Z"
40+
"2781";68259.0549329203;69987.5422080099;57210.8033286504;58116.9769610403;251002338760.54;1146844860380.54;"2024-07-29T00:00:00.000Z"
41+
"2781";58110.2984557763;62673.7639765565;49121.2373775943;58719.483169327;350584287762.92;1159042118919.04;"2024-08-05T00:00:00.000Z"
42+
"2781";58719.3952192515;61687.756592205;56161.5928697264;58483.9649819015;193731393138.94;1154518920582.08;"2024-08-12T00:00:00.000Z"
43+
"2781";58480.7127277463;64996.4201037902;57864.7095096926;64333.5441834656;200670274120.26;1270273035259.48;"2024-08-19T00:00:00.000Z"
44+
"2781";64342.2254421225;64489.7063803201;57217.8238628753;57325.4876891906;208589155271.33;1132107052433.14;"2024-08-26T00:00:00.000Z"
45+
"2781";57326.967287785;59815.056946191;52598.6996623841;54841.5663542288;226114330694.72;1083415774482.94;"2024-09-02T00:00:00.000Z"
46+
"2781";54851.8873519906;60656.7211280316;54598.4337284331;59182.8353338828;238449454690.75;1169182849928.94;"2024-09-09T00:00:00.000Z"
47+
"2781";59185.22685956;64119.530359621;57501.3391727673;63648.7098902519;223578476938.45;1257434508161.25;"2024-09-16T00:00:00.000Z"
48+
"2781";63643.1020803622;66480.6947101072;62628.0786641199;65635.3081461486;185380794223.05;1296984728119.06;"2024-09-23T00:00:00.000Z"
49+
"2781";65634.6601298628;65635.052877058;59878.8034256844;62818.9544761374;221870167579.39;1241559389621.88;"2024-09-30T00:00:00.000Z"
50+
"2781";62819.1093330048;64443.7064117964;58895.2078078197;62851.3749169602;202504726756.79;1242341595990.99;"2024-10-07T00:00:00.000Z"
51+
"2781";62848.3994880925;69359.0070607416;62442.1539998429;69001.7066212849;233833427419.27;1364212669154.26;"2024-10-14T00:00:00.000Z"
52+
"2781";69002.0001468977;69462.7367822244;65188.0352924195;67929.298795622;210764883686.53;1343230761707.59;"2024-10-21T00:00:00.000Z"
53+
"2781";67936.050186621;73569.6457967523;67535.1310128429;72246.8696680243;0;0;"2024-10-28T00:00:00Z"

‎kotlin-gradle-libraries/src/main/resources/BigMac Index.csv

+1,841
Large diffs are not rendered by default.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
package com.baeldung.kandy
2+
3+
import org.assertj.core.api.Assertions.assertThat
4+
import org.junit.jupiter.api.Test
5+
import java.io.File
6+
7+
class ChartPlotterUnitTests {
8+
@Test
9+
fun `Plot a simple bar chart`() {
10+
val simpleBarChart = BarChartPlotter()
11+
12+
simpleBarChart.plotSimpleBarChart()
13+
14+
assertThat(File("src/test/resources/charts/TiobeIndexSimple.png").exists()).isTrue
15+
}
16+
17+
@Test
18+
fun `Plot a custom bar chart`() {
19+
val customBarChart = BarChartPlotter()
20+
21+
customBarChart.plotCustomBarChart()
22+
23+
assertThat(File("src/test/resources/charts/TiobeIndexCustom.png").exists()).isTrue
24+
}
25+
26+
@Test
27+
fun `Plot a simple candlestick chart`() {
28+
val simpleCandlestickChart = CandlestickChartPlotter()
29+
30+
simpleCandlestickChart.plotSimpleCandlestickChart()
31+
32+
assertThat(File("src/test/resources/charts/BitcoinCandlestickSimple.png").exists()).isTrue
33+
}
34+
35+
@Test
36+
fun `Plot a custom candlestick chart`() {
37+
val customCandlestickChart = CandlestickChartPlotter()
38+
39+
customCandlestickChart.plotCustomCandlestickChart()
40+
41+
assertThat(File("src/test/resources/charts/BitcoinCandlestickCustom.png").exists()).isTrue
42+
}
43+
44+
@Test
45+
fun `Plot a multiplot chart`() {
46+
val multiplotChart = MultiplotChart()
47+
48+
multiplotChart.plotMultiplotChart()
49+
50+
assertThat(File("src/test/resources/charts/BigMacData.png").exists()).isTrue
51+
}
52+
}
Loading
Loading
Loading
Loading
Loading

‎pom.xml

+28
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,34 @@
336336
<artifactId>exec-maven-plugin</artifactId>
337337
<version>${exec-maven-plugin.version}</version>
338338
<executions>
339+
<execution>
340+
<id>build-kotlin-gradle-libraries</id>
341+
<phase>none</phase>
342+
<goals>
343+
<goal>exec</goal>
344+
</goals>
345+
<configuration>
346+
<workingDirectory>${project.basedir}/kotlin-gradle-libraries</workingDirectory>
347+
<executable>./gradlew</executable>
348+
<arguments>
349+
<argument>build</argument>
350+
</arguments>
351+
</configuration>
352+
</execution>
353+
<execution>
354+
<id>test-kotlin-gradle-libraries</id>
355+
<phase>none</phase>
356+
<goals>
357+
<goal>exec</goal>
358+
</goals>
359+
<configuration>
360+
<workingDirectory>${project.basedir}/kotlin-gradle-libraries</workingDirectory>
361+
<executable>./gradlew</executable>
362+
<arguments>
363+
<argument>test</argument>
364+
</arguments>
365+
</configuration>
366+
</execution>
339367
<execution>
340368
<id>build-gradle-kotlin-dsl</id>
341369
<phase>none</phase>

0 commit comments

Comments
 (0)
Please sign in to comment.