fair-acc / chart-fx

A scientific charting library focused on performance optimised real-time data visualisation at 25 Hz update rates for data sets with a few 10 thousand up to 5 million data points.
GNU Lesser General Public License v3.0
488 stars 90 forks source link

Please update documentation to included dependency for the samples #650

Closed krishnak closed 3 months ago

krishnak commented 5 months ago

Please update documentation to include dependency for the samples.

I am trying to execute this sample code

Financial Sample code

The documentation is missing the maven dependency for the samples, my VSCode auto imported samples artifactid.

The build fails as there is no import statement for the AbstractBasicFinancialApplication.

After fixing this, the build is successful, but it only opens a blank white window, no data.

Please advise how to include the dataset to execute this demo.

krishnak commented 5 months ago

Just to be on the safer side, I tried the SimpleChartSample.java

my pom.xml is as below


<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.example.chartfx</groupId>
    <artifactId>chartfx</artifactId>
    <version>1.0-SNAPSHOT</version>

    <properties>
        <maven.compiler.source>17</maven.compiler.source>
        <maven.compiler.target>17</maven.compiler.target>
    </properties>
    <dependencies>

<dependency>
    <groupId>org.openjfx</groupId>
    <artifactId>javafx</artifactId>
    <version>17.0.6</version>
    <type>pom</type>
</dependency>
  <dependency>
    <groupId>io.fair-acc</groupId>
    <artifactId>chartfx</artifactId>
    <version>11.3.0</version>
  </dependency>

    <dependency>
    <groupId>org.slf4j</groupId>
    <artifactId>slf4j-simple</artifactId>
    <version>2.0.9</version>
  </dependency>

</dependencies>

</project>

Compilation Succeeds, but no window opens up on execution.

krishnak commented 5 months ago

Regarding my first issue of financial example, it is a silly thing, the window is not maximised - its filling 2/3 of the screen so it is not showing any chart. When I maximise it - its showing. When I reduce the size it again shows a blank white window.

The SimpleChartExample doesn't even open a window.

krishnak commented 5 months ago

When executing the FinancialRealtimeFootPrintSample code - it throws the following exception

/usr/bin/env /usr/lib/jvm/bellsoft-java17-full-amd64/bin/java @/tmp/cp_3wz1qaw95j4yqavurvovy21nk.argfile io.fair_acc.sample.financial.FinancialRealtimeFootprintSample 
loading sample
Exception in Application start method
java.lang.reflect.InvocationTargetException
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:568)
        at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:465)
        at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:364)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:568)
        at java.base/sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:1082)
Caused by: java.lang.RuntimeException: Exception in Application start method
        at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:901)
        at javafx.graphics/com.sun.javafx.application.LauncherImpl.lambda$launchApplication$2(LauncherImpl.java:196)
        at java.base/java.lang.Thread.run(Thread.java:833)
Caused by: java.lang.IllegalAccessError: class io.fair_acc.chartfx.renderer.spi.financial.FootprintRenderer (in unnamed module @0x1a9823e5) cannot access class com.sun.javafx.tk.Toolkit (in module javafx.graphics) because module javafx.graphics does not export com.sun.javafx.tk to unnamed module @0x1a9823e5
        at io.fair_acc.chartfx.renderer.spi.financial.FootprintRenderer.<init>(FootprintRenderer.java:101)
        at io.fair_acc.sample.financial.FinancialRealtimeFootprintSample.prepareRenderers(FinancialRealtimeFootprintSample.java:50)
        at io.fair_acc.sample.financial.AbstractBasicFinancialApplication.getDefaultFinancialTestChart(AbstractBasicFinancialApplication.java:255)
        at io.fair_acc.sample.financial.FinancialRealtimeCandlestickSample.getChartPanel(FinancialRealtimeCandlestickSample.java:84)
        at io.fair_acc.sample.chart.ChartSample.getPanel(ChartSample.java:23)
        at fxsampler.SampleBase.buildSample(SampleBase.java:77)
        at fxsampler.SampleBase.start(SampleBase.java:31)
        at javafx.graphics/com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$9(LauncherImpl.java:847)
        at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runAndWait$12(PlatformImpl.java:484)
        at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:457)
        at java.base/java.security.AccessController.doPrivileged(AccessController.java:399)
        at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:456)
        at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:96)
        at javafx.graphics/com.sun.glass.ui.gtk.GtkApplication._runLoop(Native Method)
        at javafx.graphics/com.sun.glass.ui.gtk.GtkApplication.lambda$runLoop$11(GtkApplication.java:290)
        ... 1 more
Exception running application io.fair_acc.sample.financial.FinancialRealtimeFootprintSample
wirew0rm commented 5 months ago

Hi @krishnak,

i'm not sure I understand correctly what you are trying to archive. It sounds like you want to copy one of the samples from the samples project into a new project to use as a starting point?

Could you try first to just build the sample repository from the command line with our pom, to verify everything else is working correctly?

To answer your specific questions:

It's not really expected to use the samples artifact as a dependency, it only contains example applications and there is no efforts on our side to keep those files stable. If you want to modify a sample, I'd suggest to copy all the needed files into your repository and change the package name accordingly.

The exception in your last message relates to the Java module system, see the corresponding entry in our README on what you have to add to your run configuration. It also links to some useful background information since you might need slightly different settings depending on how and where you are running.

Additionally it's always useful to provide the OS and java(fx) versions.

krishnak commented 5 months ago

Thank you for your reply, I was trying to compile a Single sample from the index page of the project by copy pasting in to a new Visual Studio Code Project on Linux with Java Fx 17.0.6 - this information is available in the pom.xml I have posted. I assumed that it will compile with the dependency that has been documented. (that is chartfx) but the sample file (single file) compiles only with the dependency samples and not just with chartfx

I am not a UI developer and I am trying to figure out a simple way to provide the live data source as a data hook to the chart API especially the FinancialRealtimeCandlestickSample.java so that I get real time chart displayed and updated.

All the samples other than the FinancialRealtimeCandlestickSample compile and execute with just the single launcher file and using the samples artifact in maven. This one keeps throwing the error even with the command line configuration parameters

wirew0rm commented 3 months ago

I'll close this issue as using chartfx-samples as a dependency is not a supported usecase.

One of the issues i can see from your example is that that the financial samples use reflection in some of their helper classes which does not work directly (due to jigsaw), as it is not packaged in a way to be used outside of chartfx-samples itself. Most of the samples should work without the chart-fx samples, some might require one or two helper classes and for the financial samples you have to copy a bit more of the infrastructure, but this would definitely be the way to go here.

Feel free to continue to ask questions/share progress here or open specific issues if you encounter any roadblocks using the financial renderers directly via the chart.-fx dependency.