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

BarChart: non equidistand data and last data point not drawn #265

Closed
osaidmakhalfeh opened this issue Sep 24, 2020 · 5 comments · Fixed by #269
Closed

BarChart: non equidistand data and last data point not drawn #265

osaidmakhalfeh opened this issue Sep 24, 2020 · 5 comments · Fixed by #269

Comments

@osaidmakhalfeh
Copy link

Hi Dears,

I'm facing a problem while drawing a barChart with small values for the yAxis.

here is a snapshot for the values I'm trying to draw:

asas

Unfortunately, the result looks like that there is one bar rendered, but it took the full width of the screen, here is a snapshot of it.

floatissue

here is my sample to share the knowledge.
https://github.com/osaidmakhalfeh/testChartsProject/blob/master/pcCharts/src/main/java/BarChart.java

Thanks again.

@osaidmakhalfeh
Copy link
Author

@RalphSteinhagen Sorry for bothering you my friend, but please I have a question, I am using the same solution as the previous problem. I had a problem when using small numbers. the bars not rendered as expected. Can you help me?
Thank you

@RalphSteinhagen
Copy link
Member

@osaidmakhalfeh you seem to have non-equidistant data in your bar-chart (notably the point around x=20 which is about 15 units away from its neighbour).

The relative-width-based bar renderer cannot easily handle this (width ~ 1/2 distance to neighbouring point). You may want to use either a fixed spacing between x-values or a custom bar width:

   errorRenderer2.setDrawBars(true);
    errorRenderer2.setDynamicBarWidth(false);
    errorRenderer2.setBarWidth(5);

yielding something like:
image

Alternatively, you may want to check out the histogram samples and the ErrorDataSetRenderingStylingSample in particular. The latter has a UI where you can play with the various settings...

May I ask what your targeted application/use-case is? Sometimes this helps to get a feeling for what you would like to achieve. Thanks in advance and hope the above helps.

@osaidmakhalfeh
Copy link
Author

@RalphSteinhagen Thank you for your response again my amazing friend.

x -> [12.6, 12.5, 12.4, 12.3, 12.2]
y -> [1.001650853992342, 1.0000024010700712, 0.9977828294515343, 0.9974950907069192]

I tried to draw the above data on the same example project. Unfortunately, there is one problem while drawing the minimum and the maximum points. I do not know why are these two points, not rendered.
to solve this, I did something not professional, I added two dummy data points on the two sides to handle my target points.

For the app I'm working on, it's an app that reads data from a hardware sensor and handles some equations. We may use this data to do some nature-specific statistics.

@RalphSteinhagen
Copy link
Member

@osaidmakhalfeh the default ErrorDataSetRenderer setting performs a data reduction in case data points overlap i.e. if they are drawn on or nearly on the same pixel (the minimum distance is configurable).

If you have only a few data points (ie. < 1k) and do not want this point reduction feature, you may disable this by ErrorDataSetRenderer::setPointReduction(boolean). This might be useful in your case because your sample seems to have in addition non-equidistant data point distances.

@wirew0rm wirew0rm changed the title BarChar with small data values BarChart non equidistand data and last data point not drawn Sep 29, 2020
@wirew0rm wirew0rm changed the title BarChart non equidistand data and last data point not drawn BarChart: non equidistand data and last data point not drawn Sep 29, 2020
@wirew0rm
Copy link
Member

I was able to reproduce the issue with the ErrorDataSetRendererStyling sample, the inverted x-Axis seems to prevent the first and last point from being drawn.
I also noticed, that the bars vanish when panning before they would actually leave the viewport, so I guess somehow the computation of the first and last point to display gets confused when the axis is inverted.
I tried to set renderer.setAssumeSorted(false)which only lead to all points vanishing.
It also is not limited to the bar chart, but applies to all types of charts with inverted x axis. I located the bug in the ErrorDataSetRenderer and will provide a PR with a fix shortly.

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

Successfully merging a pull request may close this issue.

3 participants