Coder Social home page Coder Social logo

Comments (10)

graynk avatar graynk commented on August 11, 2024 1

Ok, so I nailed down the problem with lock. It's these two lines:
https://github.com/GSI-CS-CO/chart-fx/blob/425a8ea024bbcd4cbf14106d7dc6febd0ec9622c/chartfx-chart/src/main/java/de/gsi/chart/renderer/spi/ErrorDataSetRenderer.java#L143-L144
It first acquires read lock, and then immediately tries to acquire write lock in getXIndex of FragmentedDataSet (no such attempts are made in DoubleDataSet, that's why it doesn't hang).

from chart-fx.

graynk avatar graynk commented on August 11, 2024 1

You could use something like this. While hacking this together i found out that FragmentedDataSet does not expose its child data sets, but that is something that we can definitely change (to run this code i just added a getter).

I ended up using this approach in combination with fragDataSet.setStyle("strokeColor="), thus adding only innerDataSet.setStyle(fragDataSet.getStyle()) to the render sample. Not sure how to combine it with DefaultRenderColorScheme.strokeColorProperty() but it works anyway, thank you for the fast responses.

from chart-fx.

wirew0rm avatar wirew0rm commented on August 11, 2024 1

You can use e.g. innerDataSet.setStyle("dsIndex=0") to force all datasets to use the first entry of the color scheme.

from chart-fx.

RalphSteinhagen avatar RalphSteinhagen commented on August 11, 2024

You can change the colours via the DataSet::setStyle("strokeColor="+...) interface. Similarly, the fill colours etc. can be changed.

Regarding breaking up data into multiple bursts/sub-datasets: in increasing order of complexity you have the option of using
a) the FragmentedDataSet, or
b) deriving your own data container from AbstractDataSet to minimise the overhead/reusing some of the basic implementations, or
c) the DataSet interface directly which is another valid and great option to customise this to your own need in case you have already an existing data structure that handles your IO needs.
We use all the above depending on the specific internal use-cases.

N.B. we simplified/streamlined the 'DataSet' interface in line of multi-dimensional data treatment. So you may want to have a look at the 'x.1.0' dev branch

EDIT:

[..] So I want clear space to separate them, [..]

Sorry, overread this: we had this functionality earlier by pasting NaN values inside the dataset but (in contrast to Swing) JavaFX/GraphicsContext crashed when submitting NaN to the rendering engine -> we thus dropped this. In your case: have a look at the FragmentedDataSet example. You may derive a observable DataSet list (setting the styles of all DataSets the same9 that in turn can be added to the renderer. Just as a thought.

from chart-fx.

RalphSteinhagen avatar RalphSteinhagen commented on August 11, 2024

@graynk ... have a look at CustomColourSchemeSample

from chart-fx.

graynk avatar graynk commented on August 11, 2024

@graynk ... have a look at CustomColourSchemeSample

Thank you for your prompt response. I've compiled and installed dev version and run your example, it's exactly what I need, so thank you for that.

However, I can't seem to make FragmentedDataSet work on dev version. Here's a small change that I've made to your CustomColourSchemeSample:

FragmentedDataSet fragmentedDataSet = new FragmentedDataSet("test");
for (int i = 0; i < N_DATA_SETS_MAX; i++) {
    DoubleErrorDataSet dataSet = new DoubleErrorDataSet("Set#" + i);
    for (int n = 0; n < N_SAMPLES; n++) {
        dataSet.add(n, 0.5 * i + Math.cos(Math.toRadians(1.0 * n)), 0.15, 0.15);
    }
    fragmentedDataSet.add(dataSet);
}
chart.getDatasets().add(fragmentedDataSet);

When I run it nothing happens after primaryStage.show() and no window appears. No exceptions thrown either, nothing. Am I doing something wrong? Also not sure if it's relevant, but when I did mvn install I got this message for each of the subprojects:

Error fetching link: /home/graynk/chart-fx/chartfx-chart/target/apidocs/package-list. Ignored it.

On version 11.0.3 FragmentedDataSet works, but I'm still not quite sure how to separate the datasets, since they get connection lines all the same

image

from chart-fx.

graynk avatar graynk commented on August 11, 2024

When I run it nothing happens after primaryStage.show() and no window appears. No exceptions thrown either, nothing

Quick debug showed that after primaryStage.show() it gets stuck here on line 149, so a problem with the lock somewhere? (Adding lock().writeUnLock() throws an exception saying that it's unlocked, so that's not the problem here)
https://github.com/GSI-CS-CO/chart-fx/blob/425a8ea024bbcd4cbf14106d7dc6febd0ec9622c/chartfx-dataset/src/main/java/de/gsi/dataset/spi/FragmentedDataSet.java#L147-L162


There's also a copy-paste typo that I found, it should be setUnit here

https://github.com/GSI-CS-CO/chart-fx/blob/425a8ea024bbcd4cbf14106d7dc6febd0ec9622c/chartfx-chart/src/main/java/de/gsi/chart/axes/spi/AbstractAxisParameter.java#L1303

from chart-fx.

wirew0rm avatar wirew0rm commented on August 11, 2024

Hey, thanks for hunting down this locking bug, getXindex does not do any changes to the dataSet and should not require a write lock. I fixed this along with the copy/paste bug in df31ebd.

As for separating the data sets, this is currently not implemented in our renderers. I think what Ralph was trying to say was that you can use the FragmentedDataSet to manage all your DataSets as one DataSet but then have some code add the individual DataSets to a renderer and copy the styles from the container dataSets.

What you could do is to subclass one of the existing renderers (DoubleErrorDataSetRenderer is the default one) and override its render() function. There you can then check for FragmentedDataSet and call a DoubleErrorDataSetRenderer for all non fragmented data sets and for each of the sub-datasets (after copying the styles from the FragmentedDataSet).

EDIT: accidentally hit the comment and close button :/

from chart-fx.

wirew0rm avatar wirew0rm commented on August 11, 2024

You could use something like this. While hacking this together i found out that FragmentedDataSet does not expose its child data sets, but that is something that we can definitely change (to run this code i just added a getter).

        ErrorDataSetRenderer renderer = new ErrorDataSetRenderer() {
            @Override
            public void render(final GraphicsContext gc, final Chart chart, final int dataSetOffset,
                    final ObservableList<DataSet> datasets) {
                ObservableList<DataSet> filteredDataSets = FXCollections.observableArrayList();
                for (DataSet ds : datasets) {
                    if (ds instanceof FragmentedDataSet) {
                        final FragmentedDataSet fragDataSet = (FragmentedDataSet) ds;
                        for (DataSet innerDataSet : fragDataSet.getDatasets()) {
                            // TODO: copy style from main dataSet
                            filteredDataSets.add(innerDataSet);
                        }
                    } else {
                        filteredDataSets.add(ds);
                    }
                }
                super.render(gc, chart, dataSetOffset, filteredDataSets);
            }
        };
        chart.getRenderers().clear();
        chart.getRenderers().add(renderer);

Alternatively you could also implement a similar approach adding all datasets into one LabeledDataSet and use labels to mark the "gaps" in your data st the renderer can omit them.

from chart-fx.

wirew0rm avatar wirew0rm commented on August 11, 2024

see sample in 52b7311

from chart-fx.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.