Comments (10)
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.
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.
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.
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.
@graynk ... have a look at CustomColourSchemeSample
from chart-fx.
@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
from chart-fx.
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
from chart-fx.
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.
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.
see sample in 52b7311
from chart-fx.
Related Issues (20)
- Eclipse cannot handle 11.3.0 for some reason HOT 19
- Several questions about axis HOT 2
- The Zoomer plugin has some problems when using the mouse wheel HOT 2
- Fix usage of `renderer.getAxes` in `DataPointToolTip` and other plugins
- com.sun.javafx.application.PlatformImpl startup WARNING: Unsupported JavaFX configuration: classes were loaded from 'unnamed module @...' HOT 2
- (1) real time candlestick Chart with lines and points together (2) show at least two candlesticks together HOT 1
- Am I in the correct developer mode? developer mode for chartfx-chart/: An exception occurred while executing the Java class. Exception in Application start method HOT 1
- setTickUnit seems to be invalid and does not show the expected effect HOT 1
- ErrorDataSetRenderer with LineStyle.HISTOGRAM draws extra lines HOT 3
- Please update documentation to included dependency for the samples HOT 6
- Inquiry about Documentation HOT 1
- Broken handling of Y error values by multi-value LimitedIndexedTreeDataSet.set HOT 1
- axis auto range and axis tick label issue after `setLogAxis=true` HOT 2
- Building with Java 21 HOT 5
- Building samples as standalone fails HOT 1
- Panning mouse filter cannot be changed in the `Zoomer` plugin HOT 1
- CachedDaemonThreadFactory COMMON_POOL HOT 1
- Appearing of redundant chart axes HOT 1
- Exception in Application start method HOT 5
- Run individual sample from IntelliJ - Module javafx.graphics not found HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from chart-fx.