<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Shant Tokatyan on Medium]]></title>
        <description><![CDATA[Stories by Shant Tokatyan on Medium]]></description>
        <link>https://medium.com/@tokat.shant?source=rss-6b14c9d4e9cb------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*c2_jv9leOzb2kXTPh0nLwQ@2x.jpeg</url>
            <title>Stories by Shant Tokatyan on Medium</title>
            <link>https://medium.com/@tokat.shant?source=rss-6b14c9d4e9cb------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 00:09:17 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@tokat.shant/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Create 3D Graphs on iOS With Plot3d]]></title>
            <link>https://medium.com/better-programming/create-3d-graphs-on-ios-with-plot3d-22f2237dbcc1?source=rss-6b14c9d4e9cb------2</link>
            <guid isPermaLink="false">https://medium.com/p/22f2237dbcc1</guid>
            <category><![CDATA[mobile]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[data-visualization]]></category>
            <dc:creator><![CDATA[Shant Tokatyan]]></dc:creator>
            <pubDate>Thu, 23 Jan 2020 21:51:08 GMT</pubDate>
            <atom:updated>2020-01-27T19:57:50.350Z</atom:updated>
            <content:encoded><![CDATA[<h4>Build beautiful visualizations for your users</h4><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FL0TIZDHfoWsTUGYrkJ%2Ftwitter%2Fiframe&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2FL0TIZDHfoWsTUGYrkJ%2Fgiphy.mp4&amp;image=https%3A%2F%2Fi.giphy.com%2Fmedia%2FL0TIZDHfoWsTUGYrkJ%2Fgiphy-downsized-large.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="414" frameborder="0" scrolling="no"><a href="https://medium.com/media/8b5209426002a24275e1b5e316e75bbc/href">https://medium.com/media/8b5209426002a24275e1b5e316e75bbc/href</a></iframe><p>Plotting data in three dimensions can be a great way to visualize data if the data is plotted <em>nicely.</em> It can take creativity and brute-force iterating to come up with a useful plot of data in three dimensions.</p><p>On iOS, plotting in three dimensions is even more challenging because there aren’t many frameworks out there to use— and the only ones I found were not free!</p><p>Plot3d is an open-source project I have been working on for plotting data in three dimensions on iOS. <a href="https://cocoapods.org/pods/Plot3d">Plot3d is available on CocoaPods</a>.</p><h3>How It Works</h3><p>Plot3d uses <a href="https://developer.apple.com/documentation/scenekit">SceneKit</a> to represent data in three dimensions. The next two sections will briefly summarize the frameworks.</p><h4><strong>SceneKit recap</strong></h4><p>In SceneKit, an SCNScene is where everything that is 3D lives. Any visual object in a scene is an SCNGeometry.</p><p>A Geometry is attached to an SCNNode, which is a structural element of a scene, representing a position and transforms in a 3D coordinate space.</p><h4><strong>Plot3d overview</strong></h4><p>Plot3d provides a PlotView to manage a scene that contains all of the nodes and geometries needed to plot data in 3D. A PlotView is a subclass of UIView and everything in the scene is added to a PlotSpaceNode.</p><p>A PlotSpaceNode is the root node of a scene in a PlotView. Most of the 3D work is handled by a plot-space, which is hidden from the developer.</p><p>The data to be plotted in a plot-space is determined using a data source and delegate pattern similar to how a UITableView works.</p><h3>Using Plot3d</h3><p>To get started, just create a view with a given configuration, and then provide data. All of the code below is assumed to be in a UIViewController.</p><h4><strong>Creating a PlotView</strong></h4><p>Initialize a PlotView with a custom configuration, and set axis titles to get started.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c687b0d1b85cc1db0fe4ff6eecc4bf5d/href">https://medium.com/media/c687b0d1b85cc1db0fe4ff6eecc4bf5d/href</a></iframe><h4>Plotting in 3D</h4><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2Ff3jZImawVcaPWMjgBC%2Ftwitter%2Fiframe&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2Ff3jZImawVcaPWMjgBC%2Fsource.gif&amp;image=https%3A%2F%2Fi.giphy.com%2Fmedia%2Ff3jZImawVcaPWMjgBC%2Fgiphy-downsized-large.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="371" frameborder="0" scrolling="no"><a href="https://medium.com/media/e2adacd69626308cc0d3e6190d1e9a7b/href">https://medium.com/media/e2adacd69626308cc0d3e6190d1e9a7b/href</a></iframe><p>A plot space plots data using a PlotDataSource and a PlotDelegate. Since a PlotSpaceNode is not exposed, the data source and delegate are assigned through the PlotView.</p><p>To plot data, extend the view controller to implement the data source and delegate protocols and then assign them to the plot view.</p><pre>plotView.dataSource = self<br>plotView.delegate = self<br>plotView.reloadData()</pre><h4><strong>PlotDataSource</strong></h4><p>The data source is used to specify the number of points to plot and connections to make. The underlying plot space will iterate through the given amounts and plot each point and connection accordingly.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/37004624d1a2ba12800bfb5682b0168a/href">https://medium.com/media/37004624d1a2ba12800bfb5682b0168a/href</a></iframe><h4><strong>PlotDelegate</strong></h4><p>Below are some of the delegate methods that can be implemented to provide data to the plot space.</p><ol><li>Provides a PlotPoint (a 3D coordinate) for each point to plot. (Implementation is required.)</li><li>Provides the geometry to use at each plotted point. (Implementation is required.)</li><li>Provides the PlotText to use at each tick mark. (Implementation is optional.)</li></ol><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e716885796d72193c239505fbf0793c8/href">https://medium.com/media/e716885796d72193c239505fbf0793c8/href</a></iframe><h4><strong>Adding connections</strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FEIFtsbMaAgP9oHcHQ7RpQ.png" /><figcaption>Connections can be added by specifying the indexes of the plotted points that need to be connected.</figcaption></figure><p>We can take things one step further by adding connections between plotted points to help make the data easier to visualize.</p><p>Adding the following code to the PlotDataSource will specify the number of connections to make.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5699bd0456d9546226aafc65ac02cd16/href">https://medium.com/media/5699bd0456d9546226aafc65ac02cd16/href</a></iframe><p>Adding the following code to the PlotDelegate will specify which points to connect, and how each connection should look.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6936c2de0666fa136e19d18c2c5ca88c/href">https://medium.com/media/6936c2de0666fa136e19d18c2c5ca88c/href</a></iframe><h3>End</h3><p>The goal of Plot3d is to make it easier to develop 3D visualizations of data on iOS.</p><p>I’ll admit that there may not be a huge demand for 3D graphs on iPhones, but now I can sleep easier knowing there is an open-source option for developers. You can check out the <a href="https://github.com/stokatyan/Plot3D">source code on GitHub</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=22f2237dbcc1" width="1" height="1" alt=""><hr><p><a href="https://medium.com/better-programming/create-3d-graphs-on-ios-with-plot3d-22f2237dbcc1">Create 3D Graphs on iOS With Plot3d</a> was originally published in <a href="https://betterprogramming.pub/">Better Programming</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ScrollCounter: An Open-Source Pod for Robinhood’s Number Animation]]></title>
            <link>https://medium.com/better-programming/scrollcounter-an-ios-solution-to-the-robinhood-number-animation-bbcbd8c90355?source=rss-6b14c9d4e9cb------2</link>
            <guid isPermaLink="false">https://medium.com/p/bbcbd8c90355</guid>
            <category><![CDATA[open-source]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[cocoapods]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[mobile]]></category>
            <dc:creator><![CDATA[Shant Tokatyan]]></dc:creator>
            <pubDate>Sat, 14 Dec 2019 10:58:18 GMT</pubDate>
            <atom:updated>2019-12-15T22:45:34.395Z</atom:updated>
            <content:encoded><![CDATA[<h4>ScrollCounter brings Robinhood’s neat scrolling transition animation to iOS and CocoaPods</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ryYeCPZmKHp2uchDGRWdzQ.jpeg" /></figure><p><a href="https://robinhood.com/">Robinhood</a> is one of the best-made finance apps in the app store. That is not just my opinion; their iOS app has the rare “Editors Choice” badge that is reserved for the best-looking and feeling apps in the App Store.</p><p>Their iOS app has a number of cool UI features, and my favorite is the way they animate transitions between numbers.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FLq0RnHvS53VmYkyq9m%2Ftwitter%2Fiframe&amp;url=https%3A%2F%2Fgiphy.com%2Fgifs%2FLq0RnHvS53VmYkyq9m&amp;image=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2FLq0RnHvS53VmYkyq9m%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="286" frameborder="0" scrolling="no"><a href="https://medium.com/media/c9e26d7e4a2bbc101ea6176a3c224a0d/href">https://medium.com/media/c9e26d7e4a2bbc101ea6176a3c224a0d/href</a></iframe><p>Robinhood’s animation is not open source, so I created the <a href="https://github.com/stokatyan/ScrollCounter">ScrollCounter framework</a> for iOS and made it available through <a href="https://cocoapods.org/">CocoaPods</a>.</p><p>This article will take a high-level look at what is going on under the hood of ScrollCounter.</p><h3>How It Works</h3><h4>The pieces</h4><p>The ScrollCounter framework has three objects:</p><ol><li>ScrollableCounter:<strong> </strong>A subclass of UIView that is given an ordered array of views to scroll between.</li><li>DigitScrollCounter: A subclass of ScrollableCounter that is intended for scrolling through a range of numbers.</li><li>NumberScrollCounter: A subclass of UIView that manages a collection of DigitScrollCounters and any additional views for punctuation.</li></ol><h4>ScrollableCounter and DigitScrollCounter</h4><p>A ScrollableCounter is initialized with an array of views to scroll between and uses the indices of each element in the given array to manage scrolling animations.</p><p>From here on, we refer to the array of views as items. The elements of items can be any UIView. DigitScrollCounter is a subclass of ScrollableCounter that makes it easier to set the elements of items to a range of numbers.</p><p>To animate between the elements in items, the currently visible element is used to calculate which elements need to be &quot;scrolled through&quot; to reach the element at the desired index.</p><p>Each element in items that needs to be scrolled through is stacked vertically and all of the elements get animated at once. Checkout setupItemsToAnimate(_:_:) in ScrollableCounter for implementation details.</p><p>The animation is in a direction (up or down) so that it scrolls through the least number of elements to reach its target.</p><p>As a result, scrolling from zero to nine and scrolling from nine to zero will result in animations in different directions. Checkout calculateDirection(toIndex: Int) in ScrollableCounter for implementation details.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FdTzazRCwPqLSQaORsT%2Ftwitter%2Fiframe&amp;url=https%3A%2F%2Fgiphy.com%2Fgifs%2FdTzazRCwPqLSQaORsT&amp;image=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2FdTzazRCwPqLSQaORsT%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="372" frameborder="0" scrolling="no"><a href="https://medium.com/media/8c416eb9afefe2e2ac642a87cb017e62/href">https://medium.com/media/8c416eb9afefe2e2ac642a87cb017e62/href</a></iframe><p>The final step is handling the interruption of a scrolling animation.</p><p>We consider an animation “interrupted” when it needs to stop to allow for a new animation. This happens when the ScrollableCounter is updated while it has not completed a currently playing animation.</p><p>When an animation is interrupted, the index of the <em>most visible element</em> needs to be determined. Once an index is determined, the new elements to scroll through are stacked relative to the current element (the “current element” is the element in items that corresponds to the most visible element).</p><h4>NumberScrollCounter</h4><p>A NumberScrollCounter is a collection of DigitScrollCounters and &quot;punctuation&quot; views that are composed together to allow for scrolling through an unbounded range of numbers.</p><p>In the first place, the NumberScrollCounter lays out the DigitScrollCounters and punctuations as needed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/572/1*4kBX64VCwHI1YZYyyNkqrQ.jpeg" /><figcaption>The NumberScrollCounter arranges each DigitScrollCounter individually, and accounts for any additional views needed for punctuation.</figcaption></figure><p>When the value of the NumberScrollCounter changes, the DigitScrollCounters and punctuations are simply moved to their new target positions from wherever they currently are.</p><p>This means that no special care needs to be taken for the case of a NumberScrollCounter&#39;s animation being interrupted. Simply put, DigitScrollCounters are moved around, and faded in or out as needed.</p><p>While the layout is being animated, each individual DigitScrollCounter is animated to whichever element is required so that the NumberScrollCounter updates its value.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FiK4OHdq2wivEGM7iYE%2Ftwitter%2Fiframe&amp;url=https%3A%2F%2Fgiphy.com%2Fgifs%2FiK4OHdq2wivEGM7iYE&amp;image=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2FiK4OHdq2wivEGM7iYE%2F200.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="164" frameborder="0" scrolling="no"><a href="https://medium.com/media/bff76910b592c3f1b69c7735d7160c46/href">https://medium.com/media/bff76910b592c3f1b69c7735d7160c46/href</a></iframe><p>Finally, since a NumberScrollCounter is a subclass of UIView, it should have its frame updated as its subviews are being updated.</p><p>The frame of the NumberScrollCounter should be updated according to the final layout of its DigitScrollCounters and &quot;punctuation&quot; views.</p><p>This is simply the task of finding the minimum width and height that bounds all of the views that are used in the NumberScrollCounter. Checkout the override of sizeToFit() for implementation details.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FL2Tw7JDPLZVCSvdw9K%2Ftwitter%2Fiframe&amp;url=https%3A%2F%2Fgiphy.com%2Fgifs%2FL2Tw7JDPLZVCSvdw9K&amp;image=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2FL2Tw7JDPLZVCSvdw9K%2F200.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="136" frameborder="0" scrolling="no"><a href="https://medium.com/media/5fb340125ef374f397c20f358d363969/href">https://medium.com/media/5fb340125ef374f397c20f358d363969/href</a></iframe><h3>End</h3><p>The math involved can be a bit tedious so I omitted it from this article, but feel free to take a look at the source code for yourself and reach out if you have any questions or comments: <a href="https://github.com/stokatyan/ScrollCounter">Source code on GitHub.</a></p><p>If you made it this far in the article, I hope you found it useful, enjoy ScrollCounter!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bbcbd8c90355" width="1" height="1" alt=""><hr><p><a href="https://medium.com/better-programming/scrollcounter-an-ios-solution-to-the-robinhood-number-animation-bbcbd8c90355">ScrollCounter: An Open-Source Pod for Robinhood’s Number Animation</a> was originally published in <a href="https://betterprogramming.pub/">Better Programming</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>