ios-charts - Changing Y axis value by a drag and drop - ios

I am using ios-charts library to draw charts on a swift2 app. I am wondering if, for a given X value, I can change its Y associated value by a drag and drop gesture on the chart.
If this is not possible on this library, is it possible to do such a thing using another library?

technically you can. Every time you scroll/zoom the chart, it will trigger a redraw, so everything is redrawing, you can decide your own logic how you want the y axis value changed.
It has two parts:
In computeAxisValues in y axis renderer, the y axis labels(values) are determined. Then in renderAxisLabels, it is drawn using the calculated values.
So you can take a look at these functions and implement your logic. Note, it's your responsibility to make sure what you are doing is valid in your scenario, because if something weird happens, you may not get support on github, because it's not a bug, and sometimes not easy to answer.

Related

TeeChart 2017: FastLine AddRealTime auto scales bottom axis despite settings

The TeeChart component has a chart series called IFastLineSeries.
It allows drawing simple "line type" charts.
Its interface provides a method called AddRealTime which is a faster way to add data to the chart than the more generic AddXY method.
But AddRealTime has a few undocumented side effects:
It scrolls the chart to the left when the data almost "overflows" the view (to make room for new data)
It can adjust the bottom axis (X-axis range) to fit all data when doing so
The first feature is reasonable behavior in a lot of cases: for instance you want to keep showing the most recent process measurements as they are coming in.
However, in my case the automatic scaling for the bottom (X-axis) has been turned off. IMO it shouldn't touch the scaling settings then! But it does.
The second feature is worse: after auto scrolling, the control ensures that all the information is in view. This can slow down the application, because you may have accumulated lots of data in the fast line series which all has to be rendered then... Defeats the "is faster" philosophy behind the method...
I'm okay with the scrolling, but not with the automatic 'zoom out X' action.
Has anyone managed to get AddRealTime working without that, or is there no other choice than to fall back to the slower AddXY function?
I know I have to adjust the bottom axis myself then to achieve a similar scrolling effect, but at least it would not zoom out unexpectedly.
Remarks:
Steema software seems to know about this problem, ticket TA05011024.
Their support forums list similar if not the same problems:
How to disable autoscale with fastline series
FastLine AddRealTime ignores axis limits
You can control the behaviour you describe in the following way:
You could use Series.AddXY to avoid any of the AddRealtime's automatic behaviour; but you can anyway too, continue to use AddRealtime and modify the behaviour using your own SetMinMax of the Axis to scroll data off to the left, that way maintaining the same number of display points in the chart.
The demo here does just that and addresses your question.
Github VB TeeChart Add Realtime demo project

Live updating of chart in iOS app

My app is fetching some market live data from a web service and displaying them on a chart.
On the X axis I would have time of an event. The problem is I can have several results from the same moment or within one second, or I can have gaps there - so it's not the case that I can have a set number of x points and for each one of them - a single point on my chart. Also points on the chart won't be distributed equally on against the X axis.
I'm also looking for something that could be updated as the data flows in - including the scaling of the X and Y axis. It would be perfect if I could scroll and zoom in/out (like on a UIScrollView) the whole chart.
Is there a ready-made solution for such a case? Preferably one that allows for some good customization of its looks? I'm wondering if ios-charts could help in that?
For you first question, ios-charts does not support well for the time-style x axis, if the time range spans widely. ios-charts distribute equally for each value on x axis, so to reflect the real time-style axis, you have to generate many x values as each second/hour/day etc, but you don't add any y value for these x values.
for the second question, ios-chats can update the chart by moveViewToX, but the animation couterpart is not implemented yet. ios-charts one great feature is it supports zoom/scale for axis-based charts (excluding pie chart, radar chart). The zoom/scale is implemented via CG.
For other potential charts, if you can use swift, then there is SwiftChart, CorePlot (seems a little old) on github, and Shinobi Chart (not free)
I guess you could give a try with ios-charts, search/open issues to see if anything you needed is carried out.

shinobi chart gridline end in data point instead of going all the way to the top of chart

I'm drawing a chart in an iOS app and I want the gridlines to start in the x axis but end in the data point instead of extending all the way up to the top.
Is this possible?
Thanks in advance.
NC
Disclaimer: I work for ShinobiControls
The shinobicharts framework doesn't currently support this as an out-of-the-box feature.
A workaround may exist though. You may be able to add your own gridline subviews by using the SChartAxis method pixelValueForDataValue: to work out where in the plot area coordinate space you should draw your vertical line up to for a given data point.
Once you have your coordinates there are various ways you could draw your gridlines:
Add a canvas view behind or in front of the chart (depending on what effect you want). Then use your coordinates to draw your gridlines using CoreGraphics or some other drawing technique.
Create individual UIViews that each represent a gridline using your coordinates and add these behind or in front of the chart.
One thing to be aware of with this technique is that the gridlines will not automatically update when you pan and zoom. In order to do this you will need to override one of the chart's delegate methods that notify you of range changes and update your drawn gridlines to match the new data point positions.
Another potential workaround could be to use a column series to mimic gridlines. If you create a column series and feed it the same data points as your original series this will result in columns that go up to the y-value of each data point. You could then use the property interSeriesSetPadding on SChartAxisStyle to cause the columns to appear very thin.
I hope that information is useful!

Core Plot: Pinch to change x axis range

So I have a simple line XY Graph with integer values on the Y axis and dates on the X axis. What I would be like to be able to do is do a horizontal two-finger pinch and adjust the range dynamically. Eg, pinching in would give you a bigger range (mental model being that you're setting the start and end date shown to be further apart) and then pinching out would give you smaller time window.
Is there some stuff built in for this already? Reasonably new to CorePlot and the default finger stuff just zooms the graph itself, none of the values.
Would I need to put a gesture recgoniser on it? or does coreplot have stuff build into it for this?
Cheers
This is how the built-in zoom features work. Use a plot space delegate to monitor changes to the plot space while zooming and make changes to the axis appearance as needed based on the changes. See my answer to your other question for more info.

Coreplot: Axis Labels Fixed Location

I'm trying to customize a Coreplot graph in many ways I can and the next thing I would like to do is place the X Axis Labels (one that is custom as well) at the bottom of the graph, independent of the X axis' position (whether it's scrolled up or down).
To make it clear, it is similar to giving the labels an offset value of something like 50.0. But offset is not the property I'm looking for since it fixes the labels location relative to the X axis.
Any way this can be done? Or do I have to skip the axisLabels property and place and layer or something manually at the bottom of the graph?
EDIT: Alright, I managed to place an axis on the bottom with CPTConstraints. But it's not on the bottommost. If a plot point is on those levels, the plot line overlaps the labels. I tired padding of the graph but of course, it moves the whole graph, hence the issue persists.
Thanks in advance
Make a second x-axis. Have the first one draw the axis line, tick marks, etc., as normal but no labels. Label the second one and set all of the line style properties to nil so it doesn't draw any of the lines.
Turns out that aside from the graph, the plotAreaFrame property of the CPTGrpah also has paddings. If you give more paddings to plotAreaFrame than that of the graph, the plot will be drawn in a smaller frame and the rest of the graph area will be for you to add what you want (i.e., a second Axis).
Big thanks to #Eric, for trying to answer Every single CorePlot question as soon as possible.
CorePlot does have a lot of customisation than I thought.

Resources