<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: swapnilwatkar</title>
    <description>The latest articles on DEV Community by swapnilwatkar (@swapnilwatkar).</description>
    <link>https://dev.to/swapnilwatkar</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F461517%2F6501420e-a8c7-450f-ac19-0f4be0ace405.jpg</url>
      <title>DEV Community: swapnilwatkar</title>
      <link>https://dev.to/swapnilwatkar</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/swapnilwatkar"/>
    <language>en</language>
    <item>
      <title>Bezier Linechart in React Native</title>
      <dc:creator>swapnilwatkar</dc:creator>
      <pubDate>Thu, 15 Jul 2021 13:31:29 +0000</pubDate>
      <link>https://dev.to/swapnilwatkar/bezier-linechart-in-react-native-1flg</link>
      <guid>https://dev.to/swapnilwatkar/bezier-linechart-in-react-native-1flg</guid>
      <description>&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1lqqmkoca90xx2i8loos.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1lqqmkoca90xx2i8loos.gif" alt="Linechart" width="800" height="400"&gt;&lt;/a&gt;&lt;br&gt;
 Charts are easy way to convey data stories on mobile unlink using tables full of data especially while developing business dashboard apps, finance apps, mobile banking apps, analytics apps, e-commerce apps, health apps, and fitness apps etc.&lt;/p&gt;

&lt;p&gt;In this tutorial, we will implement Bezier Linechart in React Native. We are going to use the react-native-chart-kit library, which has the ability to add different types of charts like line charts, Pie charts, Bar charts etc to our React native apps. The library provides a Charts API that is easy to use and highly customizable.&lt;/p&gt;

&lt;p&gt;Lets Start.&lt;/p&gt;

&lt;p&gt;Installing React Native Charts Kit:&lt;/p&gt;

&lt;p&gt;Step 1: &lt;br&gt;
Install the react-native-chart-kit npm package into our existing React Native project using NPM or yarn.&lt;/p&gt;

&lt;p&gt;npm install react-native-chart-kit&lt;br&gt;
or&lt;br&gt;
yarn add react-native-chart-kit&lt;/p&gt;

&lt;p&gt;Step 2: &lt;br&gt;
Importing Charts components into React Native.&lt;br&gt;
[Note: We are using only one type of chart (Linechart) for this tutorial,there are many types like LineChart,BarChart,PieChart, ProgressChart,ContributionGraph,StackedBarChart.]&lt;/p&gt;

&lt;p&gt;You can do so by writing the following piece of code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import {LineChart} from 'react-native-chart-kit'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That’s it. Now you get access to Linechart, which are accessible from your JavaScript code.&lt;/p&gt;

&lt;p&gt;Step 3:&lt;br&gt;
Creating a Line Chart in React Native&lt;/p&gt;

&lt;p&gt;As we have already imported Linechart components in the previous step, we need to provide the data to the built-in component as follows:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;LineChart
   data={{
           labels: [Jun 21,May 21,Apr 21,Mar 21,Feb 21,Jan 21], //Array of labels [Jun 21,May 21,Apr 21,Mar 21,Feb 21,Jan 21]
             datasets: [{   data: [ 4.3,4.8,5,5,4.9,4.8 ], //Array of values 
                            color: (opacity = 1) =&amp;gt; `rgba(134, 65, 244, ${opacity})`, // optional
                            strokeWidth: 2 // optional
                        }]  
          }}
   width={label.length*10+350}
   height={320}                  
   verticalLabelRotation={70}
   withInnerLines={false}
   chartConfig={{
                  backgroundGradientFrom: 0,
                  backgroundGradientFromOpacity:0,
                  backgroundGradientTo: 0,
                  backgroundGradientToOpacity: 0,
                 color: (opacity = 1) =&amp;gt; `rgba(0, 0, 0, ${opacity})`,
                 labelColor: (opacity = 1) =&amp;gt; `rgba(0, 0, 0, ${opacity})`,
                 backgroundColor: (opacity = 0) =&amp;gt; `rgba(255, 255, 255, ${opacity})`,
                 strokeWidth: 2, // optional, default 3                       

              }}
    bezier // type of line chart              
/&amp;gt;    
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The code above represents the dataset for our bezier line chart component, that will be displayed in a line chart view, in our project.For the scope of this tutorial, we are using hardcoded static data.Check out the documentation to learn more about all the customizations you can do to a line chart at &lt;a href="https://www.npmjs.com/package/react-native-chart-kit" rel="noopener noreferrer"&gt;https://www.npmjs.com/package/react-native-chart-kit&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Run your projects and open the screen containing the newly added line chart.&lt;/p&gt;

</description>
      <category>reactnative</category>
      <category>android</category>
      <category>ios</category>
      <category>react</category>
    </item>
    <item>
      <title>How to Animate pointer on Google Map in React Native</title>
      <dc:creator>swapnilwatkar</dc:creator>
      <pubDate>Mon, 12 Jul 2021 16:43:00 +0000</pubDate>
      <link>https://dev.to/swapnilwatkar/google-map-animation-1hao</link>
      <guid>https://dev.to/swapnilwatkar/google-map-animation-1hao</guid>
      <description>&lt;p&gt;This article is to show animation of pointer movement on Google map.&lt;br&gt;
There are many ways of doing an animation of pointer movement on maps ,this article focus on using the react-native-maps.We use  MapView, Marker and AnimatedRegion for this animation.&lt;/p&gt;

&lt;p&gt;Here's what we'll create at the end of this article : &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgoc03lrznehvzwkrgqi2.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fgoc03lrznehvzwkrgqi2.gif" alt="Pointer Animation"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;For creating this animation we use the location array which has latitude and longitude values ,for example :&lt;br&gt;
{latitude: 20.93289777777778,longitude:77.77506666666666}&lt;/p&gt;

&lt;p&gt;We will update the location in state every 4 sec, so we will get the next pointer value and animate it on Map.&lt;/p&gt;

&lt;p&gt;Code sample:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const [location  ,setlocation ]=useState(0); 

 useEffect(() =&amp;gt; {                
        const interval = setInterval(() =&amp;gt; { 
             getLocation()

        },4000);
        return () =&amp;gt; clearInterval(interval)       
    })

const getLocation =  () =&amp;gt; {   
        console.log("get live location after 4 second")
let i=0; 
var locationArray=[             
{latitude:20.752219999999998,longitude:79.75849777777778},
{latitude:20.75269111111111,longitude:79.75815999999999},
{latitude:20.75293111111111,longitude:79.75798222222222}, 
{latitude:20.754004444444444,longitude:79.75805333333334},
]
const { latitude, longitude } =locationArray[i+1];
animate(latitude, longitude);
}

const animate = (latitude, longitude) =&amp;gt; {
        const newCoordinate = {latitude, longitude};
        if(Platform.OS == 'android'){
            if(markerRef.current){
            markerRef.current.animateMarkerToCoordinate(newCoordinate, 7000);
            }
        }else{
            coordinate.timing(newCoordinate).start();
        }
    }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The Complete code is available on &lt;a href="https://github.com/swapnilwatkar/GoogleMap-Animation/blob/main/MapScreen.js" rel="noopener noreferrer"&gt;https://github.com/swapnilwatkar/GoogleMap-Animation/blob/main/MapScreen.js&lt;/a&gt;&lt;/p&gt;

</description>
      <category>reactnative</category>
      <category>android</category>
      <category>ios</category>
    </item>
  </channel>
</rss>
