Elements are visible with react-visibility-sensor but the animation is not running

So I’m using react-visibility-sensor with react-spring to animate text sliding char by char from any side I want.

In my home page the animation is running smoothly, I use it twice one from the right side and another from the top side.

When I switch routes and go to another page the animation does not work.

I have my code divided in an “Title” component “Char” component and a custom hook “useAnimatedText”.

Title component:

import React from "react";
import VisibilitySensor from "react-visibility-sensor";
import useAnimatedText from "../../hooks/useAnimatedText";
import Char from './Char'


const Title = ({title, side}) => {

  // HERE I CALL A CUSTOM HOOK THAT WILL DIFINE IF THE ELEMENT IS VISIBLE OR NOT
  // AND HANDLE THE ANIMATION WHEN NECESSARY
  const [isVisible, onChange, objArray] = useAnimatedText(title)
  let elements = objArray.map((item, i) => {
   return(
     <Char 
      key={i}
      isVisible={isVisible} 
      item={item}
      delay={400 + (i * 40)}
      side={side}
     />
   )
  })
  console.log(isVisible)


  return(
    <VisibilitySensor onChange={onChange}  >
     <span className="title-box">
      <h1 className="my-heading divided-heading">
       {elements}  
      </h1>
      <hr className="title-ruller"></hr>
     </span>
   </VisibilitySensor>

 )
}

export default Title

Char component:

import { useSpring, animated } from "react-spring"


const Char = (props) => {
  const { isVisible, item, delay, isBouncy, side} = props
  const [ref, addBounce] = useBounce()
  let springConfig = {}

  if (side === 'right') {
    springConfig = {
      to: {
        opacity: isVisible ? 1 : 0,
        translateX : isVisible ? '0px' : '1000px'
      },
      config: { mass:2, tension: 200, friction: 30},
      delay: delay
    }
  }
  else if (side === 'top') {
    springConfig = {
      to: {
        opacity: isVisible ? 1 : 0,
        translateY: isVisible ? '0px' : '-500px'
      },
      config:{ mass:2, tension: 250, friction: 35},
      delay: delay
    }
  }

  const spring = useSpring({...springConfig})

  return(
    <animated.span
      style={ spring }
      className={isVisible ? 'is-visible' : 'is-not-visible'}
    >
      {item.char === ' ' ? <span>&nbsp;</span> : item.char}
    </animated.span>
  )
}

export default Char

This is the custom Hook:

import { useState } from "react";
import { stringToArray } from '../helpers'

// HOOK THAT HANDLES THE TEXT ANIMATION BY SETTING A STATE OF VISIBILITY
function useAnimatedText(string) {
  const [isVisible, setVisibility] = useState(false);

  const onChange = visiblity => {
    visiblity && setVisibility(visiblity);
  };

  let objArray = stringToArray(string)

  return [isVisible, onChange, objArray]
}

export default useAnimatedText

I did a console.log(isVisible) and the value was true but it was rendering in the page the spring values as if it was false(not visible).

I really can´t understand where I’m going wrong here, the only problem I have is when I’m not at my main route, could it be because of react-router-dom?

If someone has any clue, let me know.

Prevent user from entering smaller value than previous input

I am student testing and learning new things. Right now I’m trying to make a GUI fan speed controller. While I have made the basic code, I want that the user cant enter smaller value than previous input.

Javscript code

// 30
var range3 = document.getElementById("range3");
var num3 = document.getElementById('num3');

range3.addEventListener('input', function (e) {
num3.value = e.target.value;
});
num3.addEventListener('input', function (e) {
range3.value = e.target.value;
});


// 40
var range4 = document.getElementById("range4");
var num4 = document.getElementById('num4');

range4.addEventListener('input', function (e) {
num4.value = e.target.value;
});
num4.addEventListener('input', function (e) {
range4.value = e.target.value;
});

// 50
var range5 = document.getElementById("range5");
var num5 = document.getElementById('num5');

range5.addEventListener('input', function (e) {
num5.value = e.target.value;
});
num5.addEventListener('input', function (e) {
range5.value = e.target.value;
});


function execute(){                            
    document.getElementById("result").innerHTML =  num3.value + " " +  num4.value + " " + num5.value ;
}

HTML code

     <input id="range3"  type="range" min="0" max="100" value="0" />
        <input id="num3" min="0" max="100" type="number" value="0" />

        <input id="range4"  type="range" min="0" max="100" value="0" />
        <input id="num4" min="0" max="100" type="number" value="0" />

        <input id="range5"  type="range" min="0" max="100" value="0" />
        <input id="num5" min="0" max="100" type="number" value="0" />

        <button onclick="execute()">Click</button>
        <p id="result"></p> 

What is the most efficient way to render data from an array of object intro separate divs with map, while considering mobile and window resize?

What would be the most efficient way to render a set of data (object) into separate divs?
Let’s say I have an array like this:

 const export data = [{}, {}, {}, {}, {}, {}, {}, {}, {}, {}];

I want to map through the array and achieve this in HTML.
window width < 500px:

<div className="container">
   <div className="arrayElement"></div>
</div>
<div className="container">
   <div className="arrayElement"></div>
</div>
<div className="container">
   <div className="arrayElement"></div>
</div>
<div className="container">
   <div className="arrayElement"></div>
</div>

All that * array.length.

window width < 1000px:

<div className="container">
   <div className="arrayElement"></div>
<div className="arrayElement"></div>
</div>
<div className="container">
   <div className="arrayElement"></div>
   <div className="arrayElement"></div>
</div>
<div className="container">
   <div className="arrayElement"></div>
   <div className="arrayElement"></div>
</div>

window size > 1000px the same thing but with 3 elements inside the container.

In other words, I would like to say – Take this data, and if it’s mobile put one element into a container and create how many containers you need to fit everything. If it’s a table put 2 elements into a container and create how many containers you need. if it’s a desktop put 3 elements into a container and create how many containers you need.

So far I have tried this method witch I wound on this forum :

const Users = ({ users }) => {
    const resultsRender = [];
    
    for (var i = 0; i < users.length; i += 3) {
      resultsRender.push(
        <div className="clearfix">
        {
          users.slice(i, i + 3)
            .map(user => (
              <p>{user.name}</p>
            ))
        }
        </div>
      );
    }

  return (
    <div>
      {resultsRender}
    </div>
  );
};

const users = [{"name":"Коля","surname":"Иванов"},{"name":"Вася","surname":"Петров"},{"name":"Петя","surname":"Сидоров"},{"name":"Пётр","surname":"Иванов"},{"name":"Алейсей","surname":"Петров"},{"name":"Сергей","surname":"Сидоров"}];
      
ReactDOM.render(
  <Users users={users} />,
  root
);

With an, if statement that uses window resize I changed the number 3 in the code above. I have also added this into a useEffect and call it on window resize because otherwise if the window width would be changed the XTML would not update. The problem with this is that the XTML would update for every pixel of the window causing the server to crash.

I have also tried this:

const elementsPerDiv = mobile ? 1 : tablet ? 2 : 3;

//inside the map
return (
{elementsPerDiv % 2 < index && (
<div>
  <div>{data.something}</div>
</div>
)}
)

This had some issues as it throws some errors as the code is not really correct…

What would be a better way to achieve this? I am thinking maybe I could add this line <div className="container"> at the beginning of the array and then every elementPerDiv and this </div> every elementPerDiv.

how can i remove onkeyup on my javascript code

when i try to add a specific value with value="444" on the usd input it does not convert to the other value eth it’s only working when i enter manually the amount. how can i convert when it’s value already specified in the code

<!DOCTYPE html>
<html>
<head>
    <style>
        
    </style>
    <script src="/scripts/snippet-javascript-console.min.js?v=1"></script>
</head>
<body>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<input type="number" name="eth" class="currencyField" placeholder="ETH">
      <div class="arrow" style="margin: 0 10px";>=</div>
      <input type="number" name="usd" value="444" class="currencyField" value="" placeholder="USD">
    </div><span id="price"></span>
    <script type="text/javascript">
         $(".currencyField").keyup(function(){ //input[name='calc']
 let convFrom;
 if($(this).prop("name") == "eth") {
       convFrom = "eth";
       convTo = "usd";
 }
 else {
       convFrom = "usd";
       convTo = "eth";
 }
 $.getJSON( "https://api.coingecko.com/api/v3/coins/markets?vs_currency=usd&ids=ethereum", 
    function( data) {
    var origAmount = parseFloat($("input[name='" + convFrom + "']").val());        
    var exchangeRate = parseInt(data[0].current_price);
    let amount;
    if(convFrom == "eth")
       amount = parseFloat(origAmount * exchangeRate);
    else
       amount = parseFloat(origAmount/ exchangeRate); 
    $("input[name='" + convTo + "']").val(amount.toFixed(2));
    price.innerHTML = amount
    });
});
    </script>
</body>
</html>

How to stay Signed In for gmail api?

I want to get the messages of users by gmail api. For that google authorization is needed. I managed to authorize the user by following code –

      let authBtn = document.getElementById('authorize_button');

      const CLIENT_ID = 'XXXXXX-XXXXXXXXXXX.apps.googleusercontent.com';
      const API_KEY = 'XXXXXX-XXXXXXXXXXXXXXX';

      const DISCOVERY_DOC = 'https://www.googleapis.com/discovery/v1/apis/gmail/v1/rest';

      const SCOPES = 'https://www.googleapis.com/auth/gmail.readonly';

      let tokenClient;
      let gapiInited = false;
      let gisInited = false;

      authBtn.style.visibility = 'hidden';

      function gapiLoaded() {
        gapi.load('client', intializeGapiClient);
      }

      async function intializeGapiClient() {
        await gapi.client.init({
          apiKey: API_KEY,
          discoveryDocs: [DISCOVERY_DOC],
        });
        gapiInited = true;
        maybeEnableButtons();
      }

      function gisLoaded() {
        tokenClient = google.accounts.oauth2.initTokenClient({
          client_id: CLIENT_ID,
          scope: SCOPES,
          callback: '',
        });

        gisInited = true;
        maybeEnableButtons();
      }

      function maybeEnableButtons() {
        if (gapiInited && gisInited) {
          authBtn.style.visibility = 'visible';
        }
      }

      function handleAuthClick() {
        tokenClient.callback = async (resp) => {
          if (resp.error !== undefined) throw (resp);

          authBtn.innerText = 'Refresh';
          await getMessages();
        };

        if (gapi.client.getToken() === null) {
          tokenClient.requestAccessToken({prompt: 'consent'});
        } else {
          tokenClient.requestAccessToken({prompt: ''});
        }
      }

In above code gapi.client.getToken() === null is always false. Everytime I refresh the page I have to reauthorize user with prompt: ‘consent’.
I also want user to stay signed in until user sign out.
How can I achieve by modifying the above code?

Redux and redux toolkit having problem without using createslice

-2

I wanted to ask can’t we just simply use handwritten reducer in redux-toolkit as same as we use in redux js And then rest of all thing i may keep according tp redux-toolkit in store, but I don’t how would i able to give initialstate in configurStore please guide me I want to use same reducer function of redux handwritten instead of using createslice

Thank u

Multiple Graphs on individual Page AM Charts

Hello Gents

I am trying to display multiple charts on individual pages with chart having their own specific >area and a borderof chart on a webpage. either way it’s not working. Code files are below. JS >scripts files are same. Tried different methods but was not able to reach conclusion. All files >are available if required.

Regards

/**
 * ---------------------------------------
 * This demo was created using amCharts 5.
 * 
 * For more information visit:
 * https://www.amcharts.com/
 * 
 * Documentation is available at:
 * https://www.amcharts.com/docs/v5/
 * ---------------------------------------
 */

// Create root element
// https://www.amcharts.com/docs/v5/getting-started/#Root_element
var root = am5.Root.new("kt_amcharts_1");


// Set themes
// https://www.amcharts.com/docs/v5/concepts/themes/
root.setThemes([
  am5themes_Animated.new(root)
]);


// Create series
// https://www.amcharts.com/docs/v5/charts/flow-charts/
var series = root.container.children.push(am5flow.Chord.new(root, {
  sourceIdField: "source",
  targetIdField: "target",
  valueField: "value"
}));
series.nodes.get("colors").set("step", 2);


// Set data
// https://www.amcharts.com/docs/v5/charts/flow-charts/#Setting_data
series.data.setAll([
  { source: "Berlin", target: "Amsterdam", value: 14 },
  { source: "Berlin", target: "London", value: 33 },
  { source: "Berlin", target: "Paris", value: 13 },
  { source: "Berlin", target: "Madrid", value: 36 },

  { source: "Amsterdam", target: "Berlin", value: 42 },
  { source: "Amsterdam", target: "London", value: 20 },
  { source: "Amsterdam", target: "Paris", value: 19 },
  { source: "Amsterdam", target: "Madrid", value: 11 },

  { source: "London", target: "Amsterdam", value: 9 },
  { source: "London", target: "Berlin", value: 38 },
  { source: "London", target: "Paris", value: 41 },
  { source: "London", target: "Madrid", value: 16 },

  { source: "Paris", target: "Amsterdam", value: 12 },
  { source: "Paris", target: "London", value: 16 },
  { source: "Paris", target: "Berlin", value: 21 },
  { source: "Paris", target: "Madrid", value: 8 },

  { source: "Madrid", target: "Amsterdam", value: 22 },
  { source: "Madrid", target: "London", value: 25 },
  { source: "Madrid", target: "Paris", value: 19 },
  { source: "Madrid", target: "Berlin", value: 7 }
]);


// Make stuff animate on load
series.appear(1000, 100);
body 
    {
        font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
        background-color: azure;
    }


    .card {
        border: 1px solid #ccc;
        background-color: #f4f4f4;
        padding: 20px;
        margin-bottom: 10px;
      }
  
<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet">
        <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js"></script>
        <title>My First Website</title>
        <script src="https://cdn.amcharts.com/lib/5/flow.js"></script>
        <script src="https://cdn.amcharts.com/lib/4/core.js"></script>
        <script src="https://cdn.amcharts.com/lib/4/charts.js"></script>
        <script src="https://cdn.amcharts.com/lib/4/themes/animated.js"></script>
        <script src="https://cdn.amcharts.com/lib/5/index.js"></script>
        <script src="https://cdn.amcharts.com/lib/5/xy.js"></script>
        <script src="https://cdn.amcharts.com/lib/5/percent.js"></script>
        <script src="https://cdn.amcharts.com/lib/5/radar.js"></script>
        <script src="https://cdn.amcharts.com/lib/5/themes/Animated.js"></script>

        <link rel="stylesheet" href="style.css"
        <title>My first chart </title><br>

    </head>
    <body>
        <div class="card card-bordered">
            <div class="card-body">
                    <div id="kt_amcharts_1" style="width: 20%; height: 300px;display: inline-block;"></div>
                    <script src="chord_script1.js"></script>

                <div id="kt_amcharts_2" style="width: 20%; height: 300px;display: inline-block;"></div>
                <script src="chord_script2.js" ></script>

                    <div id="kt_amcharts_3" style="width: 20%; height: 300px;display: inline-block;"></div>
                    <script src="chord_script3.js"></script>
                </div>
            </div>
    </body>
</html>

Cannot send JSON on Get Request javascript chr2

My server does not receive the json data that is supposed to get sent across.
IS there something I am doing incorrectly. My server gets the get request with no data.

var XMLHttpRequest = require(‘xhr2’);
let getJSON = (url, callback) => {

let xhr = new XMLHttpRequest();
xhr.open('GET', url1, true);
xhr.setRequestHeader("Content-Type", "application/json");
xhr.responseType = 'json';

xhr.onload = () => {

    let status = xhr.status;

    if (status == 200) {
        callback(null, xhr.response);
    } else {
        callback(status);
    }
};
data = JSON.stringify({"url":"myurl.com"});
xhr.send(data);

};

getJSON(‘http://localhost:8000’, (err, data) => {

if (err != null) {
    console.error(err);
} else {

    console.log(data);
}

});

Deleting class from an element

I’m making a task board project.
Must say I’m using only HTML,CSS,JS and nothing else right now.
I’m making a fade in effect to newly added note (ul), and I would like to delete the fade in class from the previous added note.
this is a chunk of my code that displaying the note inside the div.

function displayAllTasks(allTasks){
taskNotesDiv.innerHTML = "";
for(const task of allTasks){
    const index = allTasks.indexOf(task);
    const note = `
    <div class"noteDiv">
    <ul class="fadeInNote">
        <button type="button" onclick="deleteTask(${index})"><i class="fa-solid fa-trash deleteButton"></i></button>
        <li>Task: ${task.task}</li>
        <li>Description: ${task.textArea}</li>
        <li>Date: ${task.date}</li>
        <li>Time: ${task.time}</li>
    </ul>
    </div>
    `
    taskNotesDiv.innerHTML += note;
}   

}

I tried already another function to delete it but no success.

any help would be appreciated!

Reuse and extend Angular component logic and template in child component

I have a form that is used to choose customer details. It is used in more than one places in my app but with extended logic and UI.
I would like to be able to reuse my basic component in other components but also to extend(or override) it’s template and logic. To don’t have to copy paste the same UI & logic in each component and have one common basic place for changes.

base component with template & logic:

@Component({
selector: 'app-base',
template: `<h1> Base component </h1>
           <label>getLabel() </label>
           <ng-content> </ng-content> `
})

export class BaseComponent implements OnInit {

constructor() {
    // base init        
}

ngOnInit(): void {
    // base ngOnInit
}

getLabel(): string {
    return "label";
    }
}

Parent component that is suppose to reuse template, being able to extend methods and lifehooks and extend the UI as well.

@Component({
selector: 'app-parent',
template: `<app-base> <h1> extended </h1> </app-base>`, 
   })

export class ParentComponent extends BaseComponent {

constructor() {
    super();    
}

ngOnInit(): void {
    super.ngOnInit();
    // extended fancy stuff        
}

getLabel(): string {
    let a = super.getLabel();
    return a + "a"; // extended logic       
       }
}

It sort of works using this approach but one problem that I noticed is that the ngOnInit is called twice. Once from the base component since I’m using its template in parent component and second time because of parentComponent ngOnInit being triggered.

Question:
Is there a way to reuse the template like using <app-base></app-base> with all shared logic in one place but without actually executing the lifehooks twice from both components?

Solution(?):
The only thing that I came up is to wrap the basic component logic with a service. So there will be something like this:

@Component({
selector: 'app-base',
template: `<h1> Base component </h1>
           <label>getLabel() </label>
           <ng-content> </ng-content> `})
export class BaseComponent implements OnInit {

constructor(IBasicService basicService) { // <-- injected service
    // base init        
}

ngOnInit(): void {
    this.basicService.onInit(); // <-- using ngOnInit from service
    // base ngOnInit
}

getLabel(): string {
    return this.basicService.getLabel(); <-- using getLabel from service
     }
}

With this approach I’ll be able to simply reuse my base component but with different injected services that will implement IBasicService interface and also simply extend the UI using or but is this correct way? Isn’t there any better solution?

Thanks in advance!

Does Node.JS include JS Promises?

I watched an interview with Ryan Dahl (the author of Node.JS) in which he regretted that he made the decision not to include Promises in Node.JS – and that this fact was among his motivations for including Promises in Deno, which conceptually seems a lot like Node.JS. However, from what I can see, Node.JS does include Promises, and I cannot see why it would not, since it is based on V8. Am I missing something?

Hiding one Div and show another with input fields

I have two divs. One is TextDivForUpdation and other is FileDivForUpdation. I am checking in Edit method of Jquery that if Filefield is empty then hide FileDivForUpdation (and only show TextDivForUpdation ) else display only FileDivForUpdation. Although, if condition works but when I try checking else condition, it gives an error in Console

jquery-3.6.0.js:8502 Uncaught DOMException: Failed to set the 'value' property on 'HTMLInputElement': This input element accepts a filename, which may only be programmatically set to the empty string.
    at HTMLInputElement.<anonymous> (https://localhost:44383/Scripts/jquery-3.6.0.js:8502:16)
    at Function.each (https://localhost:44383/Scripts/jquery-3.6.0.js:385:19)
    at jQuery.fn.init.each (https://localhost:44383/Scripts/jquery-3.6.0.js:207:17)
    at jQuery.fn.init.val (https://localhost:44383/Scripts/jquery-3.6.0.js:8472:15)
    at Object.success (https://localhost:44383/Notes/Index/13:291:51)
    at fire (https://localhost:44383/Scripts/jquery-3.6.0.js:3500:31)
    at Object.fireWith [as resolveWith] (https://localhost:44383/Scripts/jquery-3.6.0.js:3630:7)
    at done (https://localhost:44383/Scripts/jquery-3.6.0.js:9796:14)
    at XMLHttpRequest.<anonymous> (https://localhost:44383/Scripts/jquery-3.6.0.js:10057:9)

and it displays both input fields (text input field and file input field) in that modal.
I even tried displaying an Alert in else part but it is not working as well and same error message displays.

My logic: HTML:

@* Text Div For Updation *@
  <div class="row" id="TextDivForUpdation">
    <div class="col-md-3">
      <label class="control-label">Text Description: </label>
    </div>
  <div class="col-md-9">
      <textarea cols="50" rows="12" class=form-control id="TextDescriptionForUpdation" name="TextDescriptionForUpdation" placeholder="Enter Text"></textarea>
    </div>
  </div>
  <br id="textDivBrUpd" />
@* File Div For Updation *@
  <div class="row" id="FileDivForUpdation">
    <div class="col-md-3">
      <label class="control-label">File: </label>
    </div>
    <div class="col-md-9">
      <input class="form-control" type="file" placeholder="Select File" id="fileUpd" name="fileUpd" />
    </div>
  </div>
<br id="fileDivBrUpd" />

jQuery Edit Logic:

//getting data in success method 
$('#noteNameForUpdation').val(result.data.NoteName);                                  $('#TextDescriptionForUpdation').val(result.data.TextDescription);
$('#fileUpd').val(result.data.FilePath);
$('#hiddenInputFieldList').val(result.data.ListId);
$('#hiddenInputFieldNote').val(item);
var fileCheck = document.getElementById("fileUpd").files.length;

//hiding fields / divs
  if (fileCheck === null || fileCheck === "" || fileCheck === 0)
  {
    alert("Hiding File!!!!");
    $('#TextDivForUpdation').show();
    $('#textDivBrUpd').show();
    $('#FileDivForUpdation').hide();
    $('#fileDivBrUpd').hide();
  }
//error comes in else part
  else 
  {
    alert("Not Hiding!!!!");
    $('#TextDivForUpdation').hide();
    $('#textDivBrUpd').hide();
    $('#FileDivForUpdation').show();
    $('#fileDivBrUpd').show();
  }

Based on input type file, I am using if else. Can anyone guide what I am doing wrong.
Screenshot links are also attached below to understand what it looks visually.

https://imgur.com/a/wMvDHhK

https://imgur.com/a/0hCmJrd

Exported functions are not defined. Parcel/Browserify

When I use a bundler to make my JS browser compatible my exported functions are not exported.

Error: (index):11 Uncaught TypeError: connect is not a function
at HTMLButtonElement.onclick ((index):11:46)

index.js (Same root file as index.html)

const {ethers} = require("ethers");

async function connect() {
    if (typeof window.ethereum !== 'undefined') {
        await ethereum.request({method: "eth_requestAccounts"});
      }
  }

  module.exports = {
    connect
  }

index.html (Same root file as index.js)

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>HTML 5 Boilerplate</title>
    <script src="./index.js" type="module"></script>  
  </head>
  <body>
    <button id="connect" onclick="connect()">   Connect  </button>

  </body>

</html>

Using parcel, which auto creates a dist file and starts a local server.
Also tried browserify and had same issue.

Convert data to be used as Apexcharts category

first of all sorry about my english…
I am trying to present a diagram in my App which represents the clients with status active and inactive.

the data I got back from the database looks like this..

"clientsOverview": [
        {
            "date": "Mar 2022",
            "count": 1,
            "clientStatus": "inactive"
        },
        {
            "date": "Mar 2022",
            "count": 1,
            "clientStatus": "active"
        },
        {
            "date": "Apr 2022",
            "count": 2,
            "clientStatus": "active"
        },
        {
            "date": "May 2022",
            "count": 1,
            "clientStatus": "inactive"
        },
        {
            "date": "Jun 2022",
            "count": 1,
            "clientStatus": "inactive"
        },
        {
            "date": "Jun 2022",
            "count": 1,
            "clientStatus": "active"
        }
    ],

I have manipulated this data in frontend using reduce mehtode

useEffect(() => {
    const category = [] ;
    let data =[]
    clientsOverview?.map(item => {
      category.push(item.date)
    })
    data = Object.values(clientsOverview.reduce((acc, curr) => { 
      acc[curr.clientStatus] = acc[curr.clientStatus] || { name: curr.clientStatus, data: [] };
      acc[curr.clientStatus].data.push(curr.count);
      return acc;
  }, {}))
    setData(data)
    setCategory(category)
  }, [])

so my data now has this format…

"clientsOverview": [
        {
            "title": "active",
            "data": [
                1,
                2,
                1
            ]
        },
        {
            "title": "inactive",
            "data": [
                1,
                1,
                1
            ]
        }
    ],

and the array category has this format

["Mar 2022", "Mar 2022", "Apr 2022", "May 2022", "Jun 2022", "Jun 2022"]

and when I try to display this data as a chart, I end up with these results
enter image description here

<div style={{ width: "100%"}} className="pt-3">
      <ReactApexChart  
      options = {{
        chart: {
          width: 380,
        },
        xaxis: {
          categories: category
        },
        responsive: [{
          breakpoint: 480,
          options: {
            chart: {
              width: 200
            },
            legend: {
              position: 'bottom'
            }
          }
        }]
      } } 
      series= {data} type = "area" height={450} width={380}  />
    </div>

the question now if there is any way I can display my data correctly, like this
enter image description here