iOS development: interactive graph -



iOS development: interactive graph -

please take @ image above. reddish circles represent user's touching motion. if user touched first circle (to left), there should graph that's skewed left. if user touched in middle, distributed graph. if user touches right part, graph should skewed right.

i new ios development , wondering how can accomplish such feature. recommendation suitable libraries, frameworks, documents appreciated.

ok, let's go through components of 1 @ time.

to know user touches, utilize uipangesturerecognizer or uitapgesturerecognizer.

to draw curve, mutual technique add together cashapelayer:

cashapelayer *shapelayer = [cashapelayer layer]; shapelayer.strokecolor = [uicolor bluecolor].cgcolor; shapelayer.fillcolor = [uicolor clearcolor].cgcolor; shapelayer.linewidth = 4.0; [self.view.layer addsublayer:shapelayer];

you can set path cashapelayer, , every time alter path, curve on view change. if alter path (e.g. utilize uipangesturerecognizer called every time user's finger moves), animating alter of curve.

so, how create path? well, create uibezierpath

uibezierpath *path = [uibezierpath bezierpath]; [path movetopoint:...]; // build path series of curves // // [path addcurvetopoint:... // controlpoint1:... // controlpoint2:...]; // or series of lines numerous looks nice curve // // (nsinteger x = 0; x <= view.bounds.size.width; x++) { // [path addlinetopoint:...]; // } shapelayer.path = path.cgpath;

so, question whether curve needs normal distribution, or whether want draws smooth curve local maximum user touched.

if want , mathematically represents particular curve (e.g. if in center, it's true normal distribution), need come equation represent curve (as function of user tapped). draw curve plotting whole bunch of points using addlinetopoint uibezierpath.

if need looks close, can approximate 2 bezier paths (created addcurvetopoint:controlpoint1:controlpoint2:).

we're not going write you, these basic building blocks of solution. i'd suggest take these 1 @ time, little research on each, seek out, , refine. start little , build there.

ios

Comments

Popular posts from this blog

formatting - SAS SQL Datepart function returning odd values -

c++ - Apple Mach-O Linker Error(Duplicate Symbols For Architecture armv7) -

php - Yii 2: Unable to find a class into the extension 'yii2-admin' -