I'm using LineChartView to draw line charts in our application. The newest requirement is that the chart displays only 4 records at once, so the X-zoom must be limited to 4 entries. Is this achievable using this library without doing any hacky stuff? I'd rather avoid calculating zoom manually.
Thanks in advance!
If I understand correctly, you want to see only 4 values at a time.
This can be accomplished by using:
chartView.setVisibleXRange(minXRange: 4.0, maxXRange: 4.0)
The chart will be scrollable to the sides.
The scroll can be turned off, but then only the 4 first values will be viewable:
chartView.isUserInteractionEnabled = false
If you want to make the graph auto scroll along +X-axis:
let any_value_in_double = 100.00
chartView.moveViewToX(any_value_in_double)
This graph will starts moving toward the right after 4.0 values as mentioned in the above Ranges.
Related
Earlier, I asked how to create "spectra" charts in Vaadin (see How to create a "spectrum" chart using Vaadin 14+). It turned out that one didn't actually need to create barcharts -- the only real need seemed to be to set the pointwidth to 1. (This solved the "very wide" widths lines when zooming.)
HOWEVER: I think there's a bug in vaadin charts when one has more than 1 series presents and when one zooms: the line moves to an inccorrect position on the x-axis (or the x-axis is no longer placed correctly.) Any thoughts on how to resolve? Here are two screenshots showing the problem. In the first one, only ONE series is visible and the line is at the correct x-axis point of ~598.36. In the second screenshot, though, (where the only change I have made is to enable the 2nd series), the line moves to an INCORRECT x-axis coordinate (it seems like it's ~598.25!!!).
One theory I have is that adding the second series somehow confuses the chart from determining the correct x-axes....maybe because each series has it's own x axis logic in some way? Not sure....(I'm using Vaadin 14 and I tested this both in my dev env and on production.)
I have integrated a line chart in my project using Charts library and have been using it for a while now. It was working fine with few data points, however as the number of data have been increased since then the point labels (x-axis) are overlapping with each other. Is there a way to display the data-point labels without getting overlapped?
you can solve this issue using labelCount property. also, you can set using setLabelCount property, I hope this helps you.
xAxis.labelCount = 5
xAxis.setLabelCount(5, force: true)
See this post for more info: https://github.com/danielgindi/Charts/issues/1969
I was not able to find how to increase the gap between two labels on x-axis (top) however I have managed to improve the issue a little by displaying them vertically so that they are at-least visible on chart.
lineChartView.xAxis.labelRotationAngle = 270
I'm using the ios-charts library and I have a LineChart View that has x values that are dates from every weekday of this year. On the y-axis I have values between 0 and 25.
I would like to zoom in on different intervals on the LineChart View.
For example only show Data for week X one time and later change to show data for three months, etc etc.
I did not find anything in the documentation on how to do this. I used the "zoom" function with out any success.
(Example : Zoom and show the last 20 days on the x axis or zoom and show the last three months)
Has someone does this before?
It's a tough question and very advanced control. I guess you need to read carefully about the code, focusing on moveViewToX, and the logic and functions in ChartTransformer. Combining some tricks and calculations, you may find a way to fine-grainedly controll what you want to display.
Also, there is a property:
/// the maximum number of entried to which values will be drawn
internal var _maxVisibleValueCount = 100
may also help you.
I am using setVisibleXRangeMaximum(6) to set maximum x-value display, so that I display only 6 chart item at a time. When I scroll to the graph to and fro, is it possible to get the highest and least scrolled x-position?
Not 100% sure what you are asking, but it seems like
lowestVisibleXIndex, highestVisibleXIndex can help you. Take a look at these two properties.
Am trying to use the ios-charts library based off the MPAndroidCharts; however am having some trouble getting a scrollable graph to work.
By scrollable I mean that I try to show only a portion of the data of the line and that you can scroll horizontally to see more results. E.g I have 30 results and I only show 10 at a time and then scroll horizontally to see more.
Have come up with an approximation by using the method
[self.containerView setVisibleXRangeWithMinXRange:24.0f maxXRange:24.0f];
However this seems to make the scrolling kind of jittery as it keeps on redrawing.
Am looking for an ios-charts example and clarification on methods to see whether I am on the right track or not.
Similar to your question:
https://github.com/danielgindi/ios-charts/issues/267
Quote:
I was able to achieve this after playing with it a bit. It is actually pretty straight forward.
chart.data = data; // This is the MAIN reason, data for the chart has to be set first before the next 2 steps otherwise they will just get ignored like nothing has been set.
// set the max x data point to 10, which is what i wanted showing only 10 data points for the line or bar chart, from 100 data points.
[chart setVisibleXRangeMaximum:10];
// move the chart view to 90 index of X, which is the last 10 entries I want to see. and it works as expected.
[chart moveViewToX:90];
Other helpful ones:
https://github.com/danielgindi/ios-charts/issues/226
https://github.com/danielgindi/ios-charts/issues/258