Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

What is the professional way to invert xAxis values from max to min? #261

Closed
osaidmakhalfeh opened this issue Sep 22, 2020 · 17 comments
Closed

Comments

@osaidmakhalfeh
Copy link

osaidmakhalfeh commented Sep 22, 2020

Hi Dears,
First of all I want to thank you again for this amazing work!

Here, I'm trying to draw the xAxis from the "Max" to the "Min" values.
I'm not sure, how can I do it easily?

inxax

Thanks a lot

@milo-gsi
Copy link
Contributor

milo-gsi commented Sep 22, 2020

Hi osaidmakhalfeh,

this is a property of the axis.

See invertAxis(boolean)

@osaidmakhalfeh
Copy link
Author

osaidmakhalfeh commented Sep 22, 2020

Hi osaidmakhalfeh,

this is a property of the axis.

See invertAxis(boolean)
Thanks a lot for your response.
I've done that before, but unfortunately, sometimes the numbers disappeared from xAxis, here an eg.
image

@milo-gsi
Copy link
Contributor

Hi osaidmakhalfeh,

we just found that issue as I wanted to point you to one of the samples.
I'm sure it'll be fixed soon or @RalphSteinhagen / @wirew0rm will provide a workaround.

@RalphSteinhagen
Copy link
Member

@osaidmakhalfeh can you give it a try with the fixed version in the 'fix261' branch?

If you do not want to compile yourself, you can also use the snapshot repository as described here. Just enable the snapshot repository and use fix261-SNAPSHOTfor the version.

@RalphSteinhagen
Copy link
Member

... a fix a day keeps harm a way.

@osaidmakhalfeh thanks for asking a question and triggering us to fix that issue. This must-have slipped in during one of the last commits and we did not catch this earlier.

Let us know if this fixes and helps with your particular application

@RalphSteinhagen
Copy link
Member

... now merged to master. Thanks to @milo-gsi for cross-checking.

@osaidmakhalfeh
Copy link
Author

osaidmakhalfeh commented Sep 23, 2020

A lot of thanks Guys @RalphSteinhagen @milo-gsi .
Now it works!

But there are new icons that appeared after the fix.
image

I'm not sure what is that I'm trying to solve it!
Thanks again.

@RalphSteinhagen
Copy link
Member

@osaidmakhalfeh this is unrelated and the normal expected behavior. The brackets '[]' contain the units ("" as a default in this case).

In case you want to suppress this, you may want to set axis.setUnit(null);.

@osaidmakhalfeh
Copy link
Author

@osaidmakhalfeh this is unrelated and the normal expected behavior. The brackets '[]' contain the units ("" as a default in this case).

In case you want to suppress this, you may want to set axis.setUnit(null);.

That works! I mean it is related to the unit value on the axis.
Thanks again @RalphSteinhagen

My last question to you -> I tried to draw a bar from that points on the charts, but here I'm facing a new problem:

image
if you can see the dots on the top of the bar? any idea in how to remove it! or if you can reference me with a BarChart example.

Regards

@RalphSteinhagen
Copy link
Member

@osaidmakhalfeh these are the markers... can be controlled via ErrorDataSetRenderer::setDrawMarker(boolean) and other access methods (e.g. style, size, etc.)

@osaidmakhalfeh
Copy link
Author

@osaidmakhalfeh these are the markers... can be controlled via ErrorDataSetRenderer::setDrawMarker(boolean) and other access methods (e.g. style, size, etc.)

I tried what you said. But unfortunately, I'm getting the same result! maybe it is something else? !
These are the steps I did:
image

@RalphSteinhagen
Copy link
Member

@osaidmakhalfeh is your project publically available or would you perhaps have an MVP sample?

@osaidmakhalfeh
Copy link
Author

@osaidmakhalfeh is your project publically available or would you perhaps have an MVP sample?

To be honest with you, I'm on research about charts
Here I added my sample to a git repo that contains the barChart if you want to see it!

Thanks a lot @RalphSteinhagen

https://github.com/osaidmakhalfeh/testChartsProject/tree/master/pcCharts/src/main/java

@RalphSteinhagen
Copy link
Member

@osaidmakhalfeh thanks for the link: 👍

You are using DefaultErrorDatas and do not set the corresponding point errors (which default then to '0'). What you see are the squashed error bars (aka. as whiskers) around the point values and that are drawn by default by the ErrorDataSetRenderer. You can suppress these via:

errorRenderer2.setErrorType(ErrorStyle.NONE);

Also, you seem to use different DataSets to achieve different colours for a given range or particular values. This can be also achieved with one DataSet and the 'DataSet::addDataStyle(,"fillColor=<...color...>");` option. Have a look at the samples for more options how you can modify the look-and-feel of the DataSets...

E.g. taken from your code-snippet:

    // [..]
    xAxes.invertAxis(true);
    final DoubleDataSet dataSet = new DoubleDataSet("dataSet");
    dataSet.setStyle("-fx-stroke: rgb(0, 0, 0)");

    for (int i = 0; i < 200; i++) {
      dataSet.add(i, i * 2);
      if (i < 10) {
        dataSet.addDataStyle(i, "fillColor=red; markerColor=red");
      } else if (i < 50) {
        dataSet.addDataStyle(i, "fillColor=blue; markerColor=blue");
      } else {
        dataSet.addDataStyle(i, "fillColor=green; markerColor=green");
      }
    }

    errorRenderer2.getDatasets().addAll(dataSet);
    errorRenderer2.setPolyLineStyle(LineStyle.NONE);
    errorRenderer2.setErrorType(ErrorStyle.NONE);

    errorRenderer2.setDrawMarker(false);
    errorRenderer2.setDrawBars(true);
    errorRenderer2.setDynamicBarWidth(false);
    errorRenderer2.setBarWidth(5);
    errorRenderer2.setShowInLegend(false);
    errorRenderer2.setPointReduction(false);
    // [..]

yields:
image

In case you need three DataSets, then it might be better that each DataSet has a data point definition for each x-value (and the y==Double.NaN if not defined) or to attach each DataSet to a different ErrorDataSetRenderer. Otherwise, the relative bar-width calculation may get confused. You can set the bar width also to a fixed value as shown in the example snippet above (taken from your code).

Some random comments:

  • StackPane is not an ideal root container, since it doesn't manage (constrain) the size of its children. Pane(), [H,V]Box or similar seem to produce better results.
  • DataSets should have either sorted data (before adding), or the ErrorDataSetRenderer be informed that the DataSets are not sorted (i.e. via 'ErrorDataSetRenderer::setAssumeSortedData(boolean)` ), or you can use one of the DataSets that sort the added data by default (e.g. LimitedIndexedTreeDataSet or any other custom implementation).

Let us know if this helps your cause...

@osaidmakhalfeh
Copy link
Author

@RalphSteinhagen @milo-gsi

Sure, it works.

I do not know what to say,
A lot of thanks to you guys wish you all the best forever.

@RalphSteinhagen
Copy link
Member

A lot of thanks to you guys wish you all the best forever.

@osaidmakhalfeh hope this is not the last we are going to read from you. Hope the above has been useful and enjoyable!

Feel free to contact us if you have questions, bugs or just want to contribute to chart-fx (features, tutorials, examples, docs ...)

@osaidmakhalfeh
Copy link
Author

@RalphSteinhagen sure, I think I can prepare now a good docs & tutorials for others, and I will send something to you very soon.
Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants