<?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: Olowu Abraham</title>
    <description>The latest articles on DEV Community by Olowu Abraham (@thetruevillian).</description>
    <link>https://dev.to/thetruevillian</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%2F1264114%2Fa533d2c5-0ff7-4ced-a7bc-12af9298c4f2.jpg</url>
      <title>DEV Community: Olowu Abraham</title>
      <link>https://dev.to/thetruevillian</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/thetruevillian"/>
    <language>en</language>
    <item>
      <title>Exploring Git API: Fetching and Paginating All Repositories, and Displaying Single Repository Pages using React</title>
      <dc:creator>Olowu Abraham</dc:creator>
      <pubDate>Thu, 25 Jan 2024 14:59:00 +0000</pubDate>
      <link>https://dev.to/thetruevillian/exploring-git-api-fetching-and-paginating-all-repositories-and-displaying-single-repository-pages-using-react-2in5</link>
      <guid>https://dev.to/thetruevillian/exploring-git-api-fetching-and-paginating-all-repositories-and-displaying-single-repository-pages-using-react-2in5</guid>
      <description>&lt;p&gt;Step 1:  create the Repository component, you can call it anything you want. this is where are are going to call all the GitHub repositories and also perform our pagination.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Respository.jsx&lt;/strong&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Respository.jsx

import React, { useEffect, useState } from 'react'
import Eachrepo from './Eachrepo'
import axios from 'axios'

const Repositories = () =&amp;gt; {
const [reps, setReps]= useState([])
const [Error, setError]= useState(null)
const [loading, setLoading]=useState(true)
  //pignate
const [currentPage, setCurrentPage] = useState(1);
const itemsPerPage = 4;
const indexOfLastItem = currentPage * itemsPerPage;
const indexOfFirstItem = indexOfLastItem - itemsPerPage;
const currentItems = reps.slice(indexOfFirstItem, indexOfLastItem);
const totalPages = Math.ceil(reps.length / itemsPerPage);

const handlePageChange = (newPage) =&amp;gt; {
  setCurrentPage(newPage);
};

  useEffect(()=&amp;gt;{
    const fetchdata = async()=&amp;gt;{
     try{
       const rep = await axios.get(`https://api.github.com/users/abrahamsegun/repos?per_page=100`);
       const data = await rep.data;
       setReps(data)
       setLoading(false)
     } catch (error) {
       setError(error)
       setLoading(false)
       console.log(`Your code is having this ${error} error`)
     }
    }
    fetchdata();
 }, [])

 if(loading){
  return &amp;lt;div className='loading'&amp;gt;Loading ...&amp;lt;/div&amp;gt;
  }
  if(Error){
   return &amp;lt;div&amp;gt;error: {Error.message}&amp;lt;/div&amp;gt;
  }
  return (
    &amp;lt;div&amp;gt;
        &amp;lt;Eachrepo handlePageChange={handlePageChange} reps={reps} currentPage={currentPage} totalPages={totalPages} currentItems={currentItems}&amp;gt;&amp;lt;/Eachrepo&amp;gt;
    &amp;lt;/div&amp;gt;
  )
}

export default Repositories
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;First I imported axois and my react hooks to the component. then I stored my GitHub repositories API inside the reps state.&lt;br&gt;&lt;br&gt;
line 6 and line 24- 26.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//array
=&amp;gt;  const [reps, setReps]= useState([])
//update 
=&amp;gt;  setReps(data)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I handle any errors using the Error state and conditionally render my page with a loading message due to API delays.&lt;/p&gt;

&lt;p&gt;Afterward, I implemented pagination for my page from line 10 to 20. The variable names are self-explanatory, but please note that on line 15, &lt;strong&gt;reps.length&lt;/strong&gt; represents my GitHub state, which is updated as per the state defined in line 5.&lt;/p&gt;

&lt;p&gt;*&lt;em&gt;Note: *&lt;/em&gt;&lt;br&gt;
The handlePageChange function in your code is responsible for updating the currentPage state when called. This function is passed down to the Eachrepo component as a prop.&lt;/p&gt;

&lt;p&gt;step 2: Each repo component &lt;br&gt;
I decided to display in Api fetched data in the &lt;strong&gt;Eachrepo component&lt;/strong&gt; .&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Eachrepo component

import React from 'react'
import "../css/eachrepo.css"
import "../App.css"
import {Link} from "react-router-dom"

const Eachrepo = ({handlePageChange , currentItems, totalPages, currentPage, reps}) =&amp;gt; {
  return (
    &amp;lt;div className='eachrepo'id='eachrepo'&amp;gt;
      {currentItems.map((each)=&amp;gt;{
        return(
        &amp;lt;div className='singlerepo' key={each.id}&amp;gt; 

         &amp;lt;div id='smallerme'&amp;gt;&amp;lt;Link to={`/each/${each.name}`}&amp;gt; &amp;lt;h2&amp;gt;{each.name}&amp;lt;/h2&amp;gt;  &amp;lt;/Link&amp;gt;&amp;lt;/div&amp;gt;
            &amp;lt;div className='eachupdate' &amp;gt;
            &amp;lt;p id='smalleru'&amp;gt;{each.language}&amp;lt;/p&amp;gt; 
              &amp;lt;/div&amp;gt; 
              &amp;lt;/div&amp;gt;)
      })}
      &amp;lt;div&amp;gt;
       &amp;lt;div&amp;gt;
        &amp;lt;button onClick={() =&amp;gt; handlePageChange(currentPage - 1)} disabled={currentPage === 1}&amp;gt;
        Previous
        &amp;lt;/button&amp;gt;
          &amp;lt;span&amp;gt;Page {currentPage} of {totalPages}&amp;lt;/span&amp;gt;
        &amp;lt;button onClick={() =&amp;gt; handlePageChange(currentPage + 1)} disabled={currentPage === totalPages}&amp;gt;
        Next
        &amp;lt;/button&amp;gt;
      &amp;lt;/div&amp;gt;
    &amp;lt;/div&amp;gt;
    &amp;lt;/div&amp;gt;
  )
}

export default Eachrepo
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is where I displayed my repository name called &lt;strong&gt;each.name&lt;/strong&gt; from my GitHub repository array.&lt;br&gt;&lt;br&gt;
The link on link 13 is to link the repository name dynamically to new page which is connected to the Route at App.js to display page path according to the repository name&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;Route path="Repositories" element={&amp;lt;Repositories /&amp;gt;}&amp;gt;
           &amp;lt;Route path='each/:repoName' element={&amp;lt;DiplayEachRepo /&amp;gt;}&amp;gt;&amp;lt;/Route&amp;gt;
        &amp;lt;/ Route&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;Link to={`/each/${each.name}`}&amp;gt; &amp;lt;h2&amp;gt;{each.name}&amp;lt;/h2&amp;gt;  &amp;lt;/Link&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then there is a div to display two buttons to control the pages to be displayed. All the functions were passed as props from the parent component (Respository.jsx),the span tag shows the numbers and you carry out the button actions. &lt;/p&gt;

&lt;p&gt;Step 3: Individual GitHub Page.&lt;br&gt;
This is where I consumed my data based on the name of the repository. In GitHub the name of the repository leads to another array which consume here. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;DisplayeachRepo.jsx&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//DisplayeachRepo

import React, { useState, useEffect } from 'react';
import { useParams } from 'react-router-dom';
import axios from 'axios';
import { Link } from 'react-router-dom';
import '../css/display.css';

const DiplayEachRepo = () =&amp;gt; {
  const { repoName } = useParams();
  const [repository, setRepository] = useState({});

  useEffect(() =&amp;gt; {
    const fetchData = async () =&amp;gt; {
      try {
        const rep = await axios.get(`https://api.github.com/repos/abrahamsegun/${repoName}`);
        const data = await rep.data;
        // const dadada = data.find((r) =&amp;gt; r.name === repoName);
        setRepository(data);
      } catch (error) {
        console.log(error);
      }
    };
    fetchData();
  }, [repoName]);

  if (!repository) {
    return (
      &amp;lt;div className='loadingEach'&amp;gt;
        &amp;lt;div&amp;gt;Loading...&amp;lt;/div&amp;gt;
        &amp;lt;div&amp;gt;If it persists, please go back&amp;lt;/div&amp;gt;

        &amp;lt;Link to='/'&amp;gt;
          &amp;lt;button className='btn'&amp;gt;Go Home&amp;lt;/button&amp;gt;
        &amp;lt;/Link&amp;gt;
      &amp;lt;/div&amp;gt;
    );
  }

  return (
    &amp;lt;section className='bigwahala'&amp;gt;
      &amp;lt;h2&amp;gt;{repository.name}&amp;lt;/h2&amp;gt;

      &amp;lt;br /&amp;gt;
      &amp;lt;br /&amp;gt;
      &amp;lt;ul className='uldisplay'&amp;gt;
        &amp;lt;li&amp;gt;Languages: {repository.language ? repository.language : 'NONE'}&amp;lt;/li&amp;gt;
        &amp;lt;li&amp;gt;Stars: {repository.stargazers_count}&amp;lt;/li&amp;gt;
        &amp;lt;li&amp;gt;Forks: {repository.forks_count}&amp;lt;/li&amp;gt;
      &amp;lt;/ul&amp;gt;
      &amp;lt;hr /&amp;gt;
      &amp;lt;div className='hr'&amp;gt;
        &amp;lt;ul&amp;gt;
          &amp;lt;div className='issuesdiv'&amp;gt;
            &amp;lt;p&amp;gt;Issues:&amp;lt;/p&amp;gt;{' '}
            &amp;lt;p&amp;gt;
              {repository.open_issues_count &amp;gt; 0
                ? `${repository.open_issues_count} open issue(s)`
                : 'No issues'}
            &amp;lt;/p&amp;gt;
          &amp;lt;/div&amp;gt;
          &amp;lt;div className='visibitydiv'&amp;gt;
            &amp;lt;p&amp;gt; Visibility: &amp;lt;/p&amp;gt;
            &amp;lt;p&amp;gt;{repository.visibility}&amp;lt;/p&amp;gt;
          &amp;lt;/div&amp;gt;
        &amp;lt;/ul&amp;gt;
      &amp;lt;/div&amp;gt;
      &amp;lt;hr /&amp;gt;
      &amp;lt;div className='ButtonGit'&amp;gt;
        &amp;lt;button&amp;gt;
          &amp;lt;Link to={`https://github.com/abrahamsegun/${repoName}`}&amp;gt;Go to GitHub repository&amp;lt;/Link&amp;gt;
        &amp;lt;/button&amp;gt;
      &amp;lt;/div&amp;gt;
    &amp;lt;/section&amp;gt;
  );
};

export default DisplayEachRepo;



&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Clicking on each name in EachRepo will open up the individual API to be consumed here.&lt;/p&gt;

&lt;p&gt;The useParams hook provides access to the parameters of the current route. In your case, it extracts the repoName parameter from the URL. For example, if your route is "/repos/:repoName" and the user navigates to "/repos/any-repo", repoName would be equal to "any-repo".&lt;/p&gt;

&lt;p&gt;Finally, there is a GitHub link for each of them at line 69 to check the code on GitHub.&lt;/p&gt;

&lt;p&gt;Thank you. &lt;/p&gt;

</description>
      <category>webdev</category>
      <category>react</category>
      <category>api</category>
      <category>frontend</category>
    </item>
    <item>
      <title>Creating line and bar graphs in Vue.js using Chart.js through API calls</title>
      <dc:creator>Olowu Abraham</dc:creator>
      <pubDate>Tue, 23 Jan 2024 14:35:01 +0000</pubDate>
      <link>https://dev.to/thetruevillian/creating-line-and-bar-graphs-in-vuejs-using-chartjs-through-api-calls-598i</link>
      <guid>https://dev.to/thetruevillian/creating-line-and-bar-graphs-in-vuejs-using-chartjs-through-api-calls-598i</guid>
      <description>&lt;p&gt;I accomplished this task while working on a project, and I believe it would be beneficial to share the template with other developers who may find it useful in the future.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step-by-Step Guide: Creating a Line Graph with Chart.js in Vue
&lt;/h2&gt;

&lt;p&gt;Step 1: Set Up Your Vue Environment.&lt;br&gt;
Begin by setting up your Vue environment using the Vue CLI. Navigate to the 'src' folder to start your work.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm create vue@latest
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Step 2: Create a Component for Your Line Chart (e.g., Chart.vue)&lt;/p&gt;

&lt;p&gt;Create a new component to manage your line chart. You can name it, for example, Chart.vue. Before you proceed, ensure that you have installed the Chart.js library in your project, Using this command.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  npm install chart.js
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Step 3: Making API Calls&lt;/p&gt;

&lt;p&gt;In this step, you'll initiate API calls to fetch data. In my approach, I make the API call in the parent component and pass the retrieved data as a prop to the child component (Chart.js). However, you may opt to make the API call directly within the child component, depending on your preference.&lt;/p&gt;

&lt;p&gt;Parent Component (Index.vue):&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;template&amp;gt;
  &amp;lt;div&amp;gt;
    &amp;lt;div v-if="isLoading"&amp;gt;Loading please wait...&amp;lt;/div&amp;gt;
    &amp;lt;Chats :data="prices" v-if="!isLoading &amp;amp;&amp;amp; prices.length &amp;gt; 0"&amp;gt;&amp;lt;/Chats&amp;gt;
  &amp;lt;/div&amp;gt;
&amp;lt;/template&amp;gt;

&amp;lt;script setup&amp;gt;
import axios from 'axios';
import Chats from "../components/Chats.vue"
import { ref, onMounted } from 'vue';

const prices = ref([]);
const isLoading = ref(true);

onMounted(async () =&amp;gt; {
  try {
    const { data } = await axios.get(`http://localhost:5500/prices`);
    console.log('Data fetched successfully:', data);
    prices.value = data;
    isLoading.value = false;
  } catch (error) {
    console.error('Error fetching data:', error);
    prices.value = [];
    isLoading.value = false;
  }
});
&amp;lt;/script&amp;gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As shown in line 4, I use the v-if directive to display "Loading, please wait" during the API call, ensuring that the Chart component is displayed only when the data is ready. I employ an asynchronous function within the mounted lifecycle hook to consistently call the API when the page is loaded, ensuring the data is always up to date.&lt;/p&gt;

&lt;p&gt;It's important to note that I store the retrieved data in line 22 under the "price.value" ref. Storing the data in a ref is crucial as it allows for dynamic updates. I use prices.value = data; to achieve this.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;prices.value = data;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Following that, I bind the state [price] to the prop data that the Chart.vue component will utilize.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;:data="prices" 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It's essential to ensure that the data passed consists of more than one array, as indicated in &lt;br&gt;
line 5 to eliminate any potential bugs&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;v-if="!isLoading &amp;amp;&amp;amp; prices.length 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This condition ensures that the Chart component is displayed only when there is data available, and the loading process has completed.&lt;/p&gt;

&lt;p&gt;step 4:Chart.js&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;template&amp;gt;
  &amp;lt;div class="main"&amp;gt;
    &amp;lt;canvas ref="lineChart" :style='{ height: "40rem", width: "100%" }'&amp;gt;&amp;lt;/canvas&amp;gt;
  &amp;lt;/div&amp;gt;
&amp;lt;/template&amp;gt;

&amp;lt;script&amp;gt;
import Chart from 'chart.js';

export default {
  props: {
    data: Array,
  },
  data() {
    return {
      chart: null,
    };
  },
  mounted() {
    this.createChart();
  },

  methods: {
    createChart() {
      const data = this.data || [];

      const timestamps = data.map(entry =&amp;gt; new Date(entry.timestamp).toLocaleTimeString());
      const values = data.map(entry =&amp;gt; entry.value);

      this.chart = new Chart(this.$refs.lineChart.getContext('2d'), {
        type: 'line',
        data: {
          labels: timestamps,
          datasets: [{
            label: 'Value',
            data: values,
            borderColor: 'blue', // change color
            borderWidth: 2,
            fill: false,
          }],
        },
        options: {
          responsive: true,
          maintainAspectRatio: false,
          scales: {
            x: {
              type: 'linear',
              position: 'bottom',
              title: {
                display: true,
                text: 'Timestamp',
              },
            },
            y: {
              type: 'linear',
              position: 'left',
              title: {
                display: true,
                text: 'Value',
              },
            },
          },
        },
      });
    },
  },

  beforeUnmount() {
    if (this.chart) {
      this.chart.destroy();
    }
  },
};
&amp;lt;/script&amp;gt;

&amp;lt;style scoped&amp;gt;
.main {
  height: 80vh;
  width: 100%;
}
&amp;lt;/style&amp;gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;First you want to pass your props, import Chart from Chart.js and for this it is advisable you use vUE option api of vue as I did above  and I will explain why later. &lt;/p&gt;

&lt;p&gt;Now, line 15 to line 68 is provided by chartjs to run the code, but note line 27 and 28 is my x and y axis on the graph so I extracted it from from my api using the map properties. note it varies depending on you api structure. &lt;/p&gt;

&lt;p&gt;In your chartjs provided code, there is the object of x and y replace what there with with x and y text in a string. Note it must be a string is "string"&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; x: {
               type: 'linear',
                position: 'bottom',
                title: {
                  display: true,
                  text: 'Timestamp',
                },
              },
              y: {
                type: 'linear',
                position: 'left',
                title: {
                  display: true,
                  text: 'Value',
                }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To display your graph insert  component into your desired div with the ref. Dont forget your ref as shown below for line &lt;br&gt;
line 3&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;canvas ref="lineChart"&amp;gt;&amp;lt;/canvas&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The destroy() method is a Chart.js function that cleans up and removes the chart, releasing any resources associated with it.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  beforeUnmount() {
      if (this.chart) {
        this.chart.destroy();
      }
    }

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Bars
&lt;/h2&gt;

&lt;p&gt;if you want to use bar rather than line chart use the child code below. change the type and ref.&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;template&amp;gt;
  &amp;lt;div class="main"&amp;gt;
    &amp;lt;canvas ref="barChart" :style='{height:"40rem", width:"100%"}'&amp;gt;&amp;lt;/canvas&amp;gt;
  &amp;lt;/div&amp;gt;
&amp;lt;/template&amp;gt;

&amp;lt;script&amp;gt;
import Chart from 'chart.js';

export default {
  props: {
    data: Array,
  },
  data() {
    return {
      chart: null,
    };
  },
  mounted() {
    this.createChart();
  },
  methods: {
    createChart() {
      const data = this.data || [];

      const timestamps = data.map(entry =&amp;gt; new Date(entry.timestamp).toLocaleTimeString());
      const values = data.map(entry =&amp;gt; entry.value);

      this.chart = new Chart(this.$refs.barChart.getContext('2d'), {
        type: 'bar', // Change type to 'bar'
        data: {
          labels: timestamps,
          datasets: [{
            label: 'Value',
            data: values,
            backgroundColor: 'blue', // Change background color for bars if you want to
            borderWidth: 2,
          }],
        },
        options: {
          responsive: true,
          maintainAspectRatio: false,
          scales: {
            x: {
              type: 'linear',
              position: 'bottom',
              title: {
                display: true,
                text: 'Timestamp',
              },
            },
            y: {
              type: 'linear',
              position: 'left',
              title: {
                display: true,
                text: 'Value',
              },
            },
          },
        },
      });
    },
  },
  beforeUnmount() {
    if (this.chart) {
      this.chart.destroy();
    }
  },
};
&amp;lt;/script&amp;gt;

&amp;lt;style scoped&amp;gt;
.main {
  height: 80vh;
  width: 100%;
}
&amp;lt;/style&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Finally, I opted for using the Vue Option API without the setup function. The chart was originally designed to seamlessly integrate with the Vue Option API, and I encountered issues when attempting to modify the code using the Composition API. Therefore, my advice is to stick with the Option API for smoother integration and to avoid potential bugs. &lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;         `   this.chart = new Chart(this.$refs.lineChart.getContext('2d')`
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;line 30 was giving refs bug with Vue compostion api. that is &lt;/p&gt;

&lt;p&gt;&lt;code&gt;&amp;lt;script &amp;gt;&amp;lt;/script&amp;gt;&lt;/code&gt;&lt;br&gt;
instead of &lt;br&gt;
&lt;code&gt;&amp;lt;script setup&amp;gt;&amp;lt;/script&amp;gt;&lt;/code&gt; &lt;br&gt;
as used in the parent component. `&lt;/p&gt;

&lt;h2&gt;
  
  
  Outcome
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9nyb6sfompkzwm5ao4fd.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9nyb6sfompkzwm5ao4fd.jpg" alt="Image description" width="800" height="387"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
