Increase gap between two point labels in line chart - ios

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

Related

Possible bug in zooming in on Vaadin charts when more than 1 series present?

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.)

Charts for iOS: limit displayed entries number to 4 in LineChartView

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.

Scrollable Line Chart

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

Highcharts highstocks - candlestick graph has last value partially cut

In a candlestick graph i am building, the latest bar is cut-off partially such that even the bar is not visible. Thus it's difficult to judge the high and low by seeing the bar.
I'm unable to post a pic now but it's like the last rectangle being cut in half.
I'm tried a lot of options in the api but can't figure out why this is not showing correctly. The chart margin and axis offset options havent' helped. Is there a way i can set the series margin from the plot area so that it displays right.
For this problem, the best solution is to insert a dummy series which should be hidden from every aspect of the chart. So try this, insert a dummy series from the last point of the data series to some extra buffer(as per need). Then remove this series from the chart by explicitly removing it from the legends (using showinlegend),chart(setting linewidth to 0) and from tooltip by having a check in formatter. Hope this solves your problem.
I had the same problem and couldn't figure it out, because no matter how I changed the xAxis.maxPadding or changed the xAxis.max, it would always cut off the last candlestick when I clicked on the range selector.
To solve it, (hack) I just added an extra data point in my series and set it 1 day past the last day and set all values to null.
Without any code or a pic, it's hard to tell the problem, but it sounds like you need to use the max padding option. http://api.highcharts.com/highcharts#xAxis.maxPadding. You may also want to look at endOnTick as well as whether you are setting max on the axis.

How to set the bar width to a fixed value in Shinobi Charts?

I am trying to get used to Shinobi charts developed for iOS. I've downloaded trial version on same and trying to plot some sample charts using it. The charts look pretty good in demo apps. But one thing I noticed that while using class SChartColumnSeries to plot bar chart, the width of the bars is adjusted according to the frame available to plot the chart. I want it to be fixed (say 20 pixels) regardless of number of bars present and if the width required is more than what is assigned (while assigning frame to the chart) then only some part of the chart will be visible and user can scroll the chart to view remaining bars (This is possible in Core Plot). How can I achieve this using Shinobi charts?
This is possible with Shinobi, but it's not a simple case of setting a fixed width property I'm afraid. I've just tried to do this though and its isn't too complicated!
My advice would be to set up the chart like this:
chart = [[ShinobiChart alloc] initWithFrame:self.view.bounds];
[chart setAutoresizingMask:UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth];
[chart setDatasource:d];
[chart setXAxis:[SChartNumberAxis new]];
[chart setYAxis:[SChartNumberAxis new]];
[[chart xAxis] setEnableGesturePanning:YES];
[[chart xAxis] setEnableGestureZooming:NO];
[chart.xAxis setDefaultRange:[[SChartNumberRange alloc] initWithMinimum:#5 andMaximum:#10]];
The most important part is the last 3 lines. By turning zooming off you allow your charts to have a fixed zoom level, meaning the bars stay the same width. You can turn the panning on to allow users to scroll to see different bars.
The last line sets the default range. Here, i've just set it to values between 5 and 10. That means that the chart displays values between 5 and 10 along the x-axis.
By doing the above, this means that your columns will have a fixed width! You might have to do some tweaking and / or calculation depending on how many data points you have, in order to find out what you have to set your default range to. If they are variable for example, you will need to take into account the number of data points, the padding between the columns and inter column padding and the number of pixels you have available).
I realise this is quite a simplified answer but it should give you a good starting point!

Resources