Is there any way to control the Media like chrome does from the console/javascript?

The implementation is not important, but I would like to have functions or calls I can make to skip forward/backward, play/pause and a track i can move / function to call to change the song position as chrome does. This pretty much needs to only work on spotify / as a console or js insert.

This is what I am talking about:
chrome media player

I know that I can get metadata from the MediaSession API, but how can I fiddle with the playback? Mainly I care about changing the song position. However a full implementation/what I can call would be nice.

I don’t know where to start.

How to allow TikTok embed player to open application store?

I’m trying to embed TikTok player using https://developers.tiktok.com/doc/embed-player?enter_method=left_navigation.

When interacting with comments button on mobile devices without having TikTok app installed – default behaviour is to redirect App store.

But, it doesn’t work, and instead throws an error:
Not allowed to launch '<URL>' because a user gesture is required.
Breaking the whole player.

How do I allow iframe to perform this redirect?

Sound doesn’t play until interacting with the page

I’m trying to add a sound effect to my page when the user scrolls with his mouse wheel.
When the page is loaded up and the user scrolls, the listener works as expected but the sound isn’t being played.
Only when I interact with the page (for example by clicking with my mouse) and then scroll then I can hear the scrolling sound effect.
I tried playing the sound through my JS script one time with volume to 0 but didn’t solve the problem.
Even manually adding a document.click() at the start of the script didn’t help.

JS code:

click.preload = 'auto';

var sc = new Audio("/SND/scroll.wav");
sc.preload = 'auto';

// Tried to autoplay the sound one time
sc.volume = 0.0;
sc.play();
sc.volume = 1.0;
sc.pause();
sc.currentTime = 0;

function playClick(evt){
    if(evt.target.nodeName == "input" ||
       evt.target.id == "arrw_l" ||
       evt.target.id == "arrw_r"
    ){
        click.currentTime = 0; click.play();
    }
}

function playScroll(evt){
    sc.currentTime = 0; sc.play();
}

window.onload = function(){
    document.addEventListener('wheel', playScroll);
    document.addEventListener('click', playClick);
}

Using jontjs in a more declarative way in react, misuse of react.useEffect?

The React tutorial of joint js shows a way to use jointjs in react. The tutorial is quite limited: it is basically defining a special named div and putting all jointjs code inside.

The jointjs definition also looks quite different to standard react component definitions, really like an imperative instead of declarative solution, where I could do something along the lines of, to have a paper with a rectangle on it:

return <div>
    <Paper width={300} height={300} background={{ color: '#F5F5B5' }} cellViewNamespace={namespace}>
        <Rect x={100} y={150} width={80} height={40}/>
    </Paper>
</div>

While the idea is one thing, the implementation is where I am starting to doubt, my current prototype looks like:

export const Paper = (props: PropTy) => {
    const paperEl = useRef(null);
    const graph = useRef(new Graph({}, {cellNamespace: shapes}))

    const paper = useRef<dia.Paper|undefined>();

    const {
        children
        // ... all paper props
    } = props;

    useEffect(() => {
        if (graph) {

            paper.current = new dia.Paper({
                el: paperEl.current,
                model: graph.current,
                // ... remaining paper props
            });
        }


        return () => {
            if (paper.current) {
                paper.current.stopListening();
                paper.current = undefined;
            }
        };
    }, [
        graph,
        // ... paper props
    ]);

    return (
        <GraphContext.Provider value={graph.current}>
            <div ref={paperEl} />
            {children}
        </GraphContext.Provider>
    );
}


export function Rect(props: RectProps) {
    const graph = useContext(GraphContext)
    const {x, y, width, height} = props;

    useEffect(() => {
        console.log("made rect")
        const rect = new shapes.standard.Rectangle();
        rect.position(x, y);
        rect.resize(width, height);
        rect.addTo(graph);
        return () => {
            console.log("remove rect");
            rect.remove();
        }
    }, [graph, x, y, width, height]);

    return <></>
}

While this works for the simple example, this seems to be misusing the useEffect? As all logic is basically hidden in a use effect and the return isn’t used at all. All the while I keep reading more and more documentation that You might not need use Effect. So is there a better “solution” to this?


I have also a second idea, where instead of directly modifying the graph in the inner components, the inner components just update a list of “elements”, available as a map each render. And the “Paper” component is just responsible for rendering the map to the graph each time the paper is rerendered.

Czy ktoś wie co jest nie tak z moim kodem? Mam problem z wyświetlaniem obrazów [closed]

Robię grę typu Idle/Clicker w html i mam problem z generacją obrazów. Poniżej podana jest moja główna lista gdzie są wszystkie potrzebne rzeczy do pokazania obrazu oraz funkcja która powinna te obrazy pokazać

    var KlapkiType = {

    img: [      // ZDJĘCIE KLAPEK
        'Images/KlapkiCzarne-1.png', 'Images/KlapkiBrązowe-2.png', 'Images/KlapkiPomarańczowe-3.png', 'Images/KlapkiŻółte-4.png', 'Images/LekkoRóżoweKlapki-5.png','Images/KlapkiRóżowe-6.png','Images/KlapkiFioletowe-7.png','Images/KlapkiZielone-8.png','Images/KlapkiGruszkowe-9.png','Images/KlapkiLimonkowe-10.png','Images/KlapkiNieba-11.png','Images/KlapkiCzerwone-12.png','Images/KlapkiNiebieskie-13.png','Images/KlapkiNajemnicze-14.png'
    ],

    nazwa: [    // NAZWA KLAPEK
        'Zwykłe Klapki','Shitty Klapki','Pomarańczowe Klapki','Cytrynowe Klapki','Chłopięce Klapki','Męskie Klapki','Klapki Gonia','KlapkiLecha','Gruszkowe Klapki','Klapki Scouta','Niebiańskie Klapki','Klapki Lumika','Wodne Klapki','Najemnicze Klapki'
    ],

    koszt: [    // KOSZT KLAPEK
        10, 250,5000,75000,250000,1000000,7500000,25000000,200000000,1000000000,25000000000,500000000000,2500000000000,100000000000000
    ],

    income: [   // PRZYCHÓD KLAPEK
        1, 20,250,10000,15000,100000,1000000,4000000,20000000,125000000,1000000000,25000000000,275000000000,5000000000000
    ]

}


    function klapkiGenerate() {      // WYGENERUJ OBRAZY KLAPKÓW W PRAWYM KONTENERZE
    
        document.getElementById('KlapkiContainer').innerHTML = ''
        for (i=0 ; i<=KlapkiType.length ; i++) {
            document.getElementById('KlapkiContainer').innerHTML += '<div class="AutoKlapkiContainer" style="background-color: rgb(108, 75, 15);"><img id="klapekClick" src='+KlapkiType.img[i]+' onclick="BuyKlapki('+i+')"><p><span id="klapekKoszt">0</span></p><p><span id="klapekIncome">0</span></p> <p><span>'+KlapkiType.nazwa[i]+'</span></p></div>'
            document.getElementsByName('klapekKoszt').textContent = KlapkiType.koszt[i]
            document.getElementsByName('klapekIncome').textContent = KlapkiType.income[i]
            
        }
    
    }

Próbowałem rzeczy takich jak zmiana listy z [] na {} ale nic nie się nie zmieniło

Import jquery-form with vite

Yes, call me old, I am still using jQuery 🙂

I am converting an old web page (using jQuery with jquery-form plugin obviously) to Vite with ES6 syntax. I am having issues using jquery-form plugin. My Javascript knowledge is not that good. I succussed to import the plugin, but the form I am submitting is submitted directly (not through ajaxForm()).

import jQuery from "jquery";

window.$ = window.jQuery = jQuery;
import jqueryForm from 'jquery-form';

$.fn.ajaxForm = jqueryForm;

$('#update_form').ajaxForm({
    delegation: true,
    uploadProgress: function (event, position, total, percentComplete) {
        //Update progress
    },
    success: function (result) {
        //handle request success
    },
    error: function (xhr, ajaxOptions, thrownError) {
        //handle request error
    },
});

No error is shown in the console, and the upload is successful. But it is like ajaxForm() is not been called at all.

How to append a created html element to another html file?

const button1 = document.getElementById('1');
const button2 = document.getElementById('2');

const main = document.getElementById('main');

function myFunc() {

    const elem = document.createElement('h1');

    button1.onclick = () => {

        location.assign('2.html');
        elem.textContent = '1';
        
            if (location.pathname === '/2.html') {
                main.appendChild(elem);
            }
        }

    button2.onclick = () => {
        location.assign('2.html');
        elem.textContent = '2';
        
            if (location.pathname === '/2.html') {
                main.appendChild(elem);
            }
    }
}

myFunc();
<button id="1" style="width: 100px; height: 30px;">Click</button>
<button id="2" style="width: 100px; height: 30px;">Click</button>

<main id="main"></main>

I have two buttons inside the first html file, and a main div inside the second html file. When I press a button inside the first html file, I want to update the second, by appending the h1 elem with the adequate textContent. Both html files are connected to the same js file. I tried doing it with pathname conditional, but it’s not working.

How to dismiss a bootstrap modal after a form is successfully filed?

I am learning HTML, CSS, JS and PHP and put on myself to make a page with lets the user leave a message, but i have not being able to implement a way to make the modal close after the user correctly submits the form.

here is the part of the CODE:

[...]
<div class="modal fade" id="messagebook" data-bs-backdrop="static" data-bs-keyboard="false" tabindex="-1" aria-labelledby="staticBackdropLabel" aria-hidden="true">
          <div class="modal-dialog modal-dialog-centered modal-dialog-scrollable modal-lg">
            <div class="modal-content">
              <div class="modal-header">
                <h1 class="modal-title fs-5" id="staticBackdropLabel">Write a message:</h1>
                <button type="button" class="btn-close" onclick="clearForm()" data-bs-dismiss="modal" aria-label="Close"></button>
              </div>
              <form onsubmit="event.preventDefault(); save();">
                <div class="modal-body">
                  <fieldset>
                    <input type="hidden" id="id">
                    <div class="book">
                      <label for="user">User:</label><br>
                      <input type="text" id="user" name="user" required>
                    </div>
                    <div class="book">
                      <label for="email">E-mail:</label><br>
                      <input type="email" id="email" name="email" required>
                    </div>
                  </fieldset>
                  <fieldset>
                    <div class="book">
                      <label for="message">Message:</label><br>
                      <textarea type="text" id="message" name="message" rows="5" cols="30" required></textarea>
                    </div>
                  </fieldset>
                </div>
                <div class="modal-footer">
                  <button type="submit" id="sub" class="but">Send</button>
                </div>
              </form>
            </div>
          </div>
        </div>
      </section>
    </main>
    <br>
[...]
    <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz" crossorigin="anonymous"></script>
    <script src="SiteAjs.js"></script>
[...]

How do i configure the vercel.json app to allow routes like /api/items

i am trying to configure my vercel.json file so that when i visit my backend app hosted in vercel, i am able to see the routes working properly.
However, when i do this, the only route working is the / route and i can see the message, but the api/…routes are not working. I have been trying to host my backend app to vercel for hours now and everytime i seem to be through one problem another on appears.
This app works as expected in localhost, i have never hosted a backend app in vercel before thats why i am having problems.

    {
    "version": 2,
    "builds": [
        {
            "src": "./index.js",
            "use": "@vercel/node"
        }
    ],

    "headers": [
        {
            "source": "/api/(.*)",
            "headers": [
                {
                    "key": "Access-Control-Allow-Origin",
                    "value": "https://to-my-frontend"
                },
                {
                    "key": "Access-Control-Allow-Methods",
                    "value": "GET, POST, PUT, DELETE, OPTIONS"
                },
                {
                    "key": "Access-Control-Allow-Headers",
                    "value": "Content-Type, Authorization"
                }
            ]
        }
    ]
}

Here is my index.js:

    const express = require('express');
const cors = require('cors');
const bodyParser = require('body-parser');
const connectDb = require('./config/connectToDb');

const app = express();

// Enable CORS for the specified origin
app.use(cors({
    origin: 'https://to-frontend-app',
    methods: ['GET', 'POST', 'PUT', 'DELETE', 'OPTIONS'],
    allowedHeaders: ['Content-Type', 'Authorization']
}));

app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));

// Import routes
const userRoutes = require('./routes/userRoute');
const itemRoutes = require('./routes/itemsRoute');

// Use routes
app.use('/api', userRoutes);
app.use('/api', itemRoutes);

// Connect to database
connectDb();

// Default response for root
app.get('/', (req, res) => {
    res.json({ message: 'Welcome to the API' });
});

// Export the Express app as a module
module.exports = app;

Someone help

Howto set a js value for an input

very simple question, I want to dynamically generate a uuid.v4() as the value attribute of an input :

<input type="text" id="token" value=uuid.v4()>

I tried this right after the input :

<script>document.getElementById("token").value=uuid.v4()</script>

but it’s not better.

Thanks

Add a button on elementor add new section in edit page

I want to add a button in elementor add new section on edit page. In my plugin root file I just enqueued the js file only. I ensured that the js file was loaded perfectly and in console I can see at last this console.log(‘Elementor initialized’);. If anyone can solve the issue please help me. For clarification, I just want to add a button only.

See the image for more clear The image is

    console.log('custom-button.js loaded');

jQuery(window).on('elementor:init', function() {
    console.log('Elementor initialized');

    elementor.hooks.addAction('editor/init', function() {
        console.log('Editor initialized');

        const interval = setInterval(() => {
            const targetContainers = document.querySelectorAll('.elementor-add-new-section, .e-view');

            console.log('Checking for target containers:', targetContainers);

            if (targetContainers.length > 0) {
                targetContainers.forEach((container, index) => {
                    console.log(`Container ${index} found`, container);
                    
                    if (container.classList.contains('e-view')) {
                        const buttonDiv = document.createElement('div');
                        buttonDiv.classList.add('elementor-add-section-area-button');

                        const newButton = document.createElement('button');
                        newButton.textContent = 'Add New Section';
                        newButton.classList.add('button', 'button-primary');

                        buttonDiv.appendChild(newButton);
                        container.appendChild(buttonDiv);
                        console.log('Button added to the editor');

                        clearInterval(interval);
                    }
                });
            } else {
                console.log('No matching target containers found yet');
            }
        }, 500); 
    });
});

Layout was forced before the page was fully loaded

After making some CSS changes to the website, this message appeared in the FireFox console:

Layout was forced before the page was fully loaded. If stylesheets are not yet loaded this may cause a flash of unstyled content.

How to solve this? This problem sometimes causes fonts to not load properly. I tried to resolve this message by gradually removing all the code. All the code used is simple css from bootstrap.

I tried various methods, such as:

  • adding an empty script tag at the end of the head or at the beginning of the body.
  • reverting the changes to the previous state did not fix the problem!
  • moving all script tags at the end
  • removing all javascript and css codes!

here is that css change (just added)

.big-slider .owl-item .written .text span, .big-slider .owl-item .written .text strong, .big-slider .owl-item .written .text p {
            font-family: 'IRANYekanXVF';
        }

here is my html code:

<!DOCTYPE html>
<html lang="fa" dir="rtl">
<head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0 ,user-scalable=no" />
    <title>Sample Title</title>
    
    <meta http-equiv="content-language" content="fa" />

    <link rel="preload" as="font" href="/content/font/YekanXProVar/webfont/IRANYekanXVF.woff" type="font/woff" crossorigin="anonymous" />
    <link rel="preload" as="font" href="/content/font/YekanXProVar/webfont/staticfonts/IRANYekanX-regular.woff" type="font/woff" crossorigin="anonymous" />
    <link rel="preload" as="font" href="/content/font/YekanXProVar/webfont/staticfonts/IRANYekanX-bold.woff" type="font/woff" crossorigin="anonymous" />

    <link rel="manifest" href="/manifest.json" />
    <meta name="msapplication-TileColor" content="#f5f5f5" />
    <meta name="msapplication-TileImage" content="/content/load/Gabz144.png" />
    <meta name="theme-color" content="#f5f5f5" />

    <meta name="referrer" content="always" />
    <meta name="language" content="fa" />
    <meta name="document-type" content="Public" />
    <meta name="document-rating" content="General" />
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="resource-type" content="document" />

    <link rel="apple-touch-icon" href="/content/load/Gbaz32.png" />
    <link rel="shortcut icon" type="image/x-icon" href="/favicon.ico">
    <link rel="icon" type="image/x-icon" href="/favicon.ico" />
    <meta name="author" content="sample author" />
    <meta name="keywords" content="sample Keywords " />
    <meta name="description" content="sample descr" />
    
    <script>
        /*to prevent Firefox FOUC, this must be here*/
        let FF_FOUC_FIX;
    </script>
</head>
<body>
    <script>0</script>
... every things here ...
</body>
</html>

Issues with installing pod after installing react-native-onesignal: RuntimeError – `PBXGroup` attempted to initialize an object with unknown

After installing react-native-onesignal
I got this error

RuntimeError - `PBXGroup` attempted to initialize an object with unknown ISA `PBXFileSystemSynchronizedRootGroup` from attributes: 
{
  "isa"=>"PBXFileSystemSynchronizedRootGroup", 
  "exceptions"=>["0B2BF25A2CE09BA200A86A8F"], 
  "explicitFileTypes"=>{}, 
  "explicitFolders"=>[], 
  "path"=>"OneSignalNotificationServiceExtension", 
  "sourceTree"=>"<group>"
}

I am making an aviator game, but I face issue on making the graph, the y-axis and x-axis not run according to the multiplier value

Graph image

As you can see in the picture, the y-axis is not according to the multiplier value
Here is the graph code,

import React, { useState, useEffect, useRef, useCallback } from "react";
import { io } from "socket.io-client";
import { Line } from "react-chartjs-2";
import {
  Chart as ChartJS,
  CategoryScale,
  LinearScale,
  PointElement,
  LineElement,
  Filler,
  Title,
  Tooltip,
  Legend,
  ChartOptions,
} from "chart.js";

ChartJS.register(
  CategoryScale,
  LinearScale,
  PointElement,
  LineElement,
  Filler,
  Title,
  Tooltip,
  Legend
);

export default function Component() {
  const [gameState, setGameState] = useState("waiting");
  const [dataPoints, setDataPoints] = useState([1]);
  const [timePoints, setTimePoints] = useState([0]);
  const [countdown, setCountdown] = useState(0);
  const [crashPoint, setCrashPoint] = useState(1);
  const [currentMultiplier, setCurrentMultiplier] = useState("1.00");
  const multiplierRef = useRef<number>(parseFloat(currentMultiplier));
  const startTime = useRef(Date.now());
  const socket = useRef<ReturnType<typeof io> | null>(null);
  const gameInterval = useRef<NodeJS.Timeout | null>(null);
  const [, setIsBetting] = useState(false);

  // Initialize localStorage and multiplier once the component is mounted
  useEffect(() => {
    if (typeof window !== "undefined" && localStorage.getItem("currentMultiplier")) {
      const storedMultiplier = localStorage.getItem("currentMultiplier");
      setCurrentMultiplier(storedMultiplier || "1.00");
      multiplierRef.current = parseFloat(storedMultiplier || "1.00");
    }
  }, []);

  const updateGraph = useCallback(() => {
    const elapsed = (Date.now() - startTime.current) / 1000;
    setTimePoints((prev) => [...prev, elapsed]);

    // Simulate exponential growth for the graph (does not affect actual multiplier)
    const exponentialMultiplier = Math.exp(elapsed / 10); // Adjust '10' for faster/slower growth
    setDataPoints((prev) => [...prev, exponentialMultiplier]);

    const formattedMultiplier = parseFloat(multiplierRef.current.toFixed(2)).toString();
    setCurrentMultiplier(formattedMultiplier);
    if (typeof window !== "undefined") {
      localStorage.setItem("currentMultiplier", formattedMultiplier); // Store the multiplier
    }
  }, []);

  const startGame = useCallback(() => {
    setGameState("playing");
    startTime.current = Date.now();
    setDataPoints([1]);
    setTimePoints([0]);
    setIsBetting(true);

    if (gameInterval.current) {
      clearInterval(gameInterval.current);
    }

    gameInterval.current = setInterval(() => {
      updateGraph();
    }, 50);
  }, [updateGraph]);

  const resetGame = useCallback(() => {
    setCountdown(0);
    setDataPoints([1]);
    setTimePoints([0]);
    setCrashPoint(1);
    multiplierRef.current = 1;
    setGameState("waiting");
    setIsBetting(false);

    if (gameInterval.current) {
      clearInterval(gameInterval.current);
    }
  }, []);

  const startCountdown = useCallback(() => {
    let count = 5;
    setCountdown(count);

    const countdownInterval = setInterval(() => {
      count -= 1;
      setCountdown(count);

      if (count === 0) {
        clearInterval(countdownInterval);
        startGame();
      }
    }, 1000);
  }, [startGame]);

  useEffect(() => {
    const newSocket = io("http://localhost:3076", {
      transports: ["websocket"],
      withCredentials: true,
    });

    socket.current = newSocket;

    newSocket.on("gameState", (state) => {
      if (state.status === "playing") {
        setGameState("playing");
        multiplierRef.current = parseFloat(state.currentMultiplier) || 1;
        startTime.current = Date.now();

        setDataPoints([multiplierRef.current]);
        setTimePoints([0]);
        const formattedMultiplier = multiplierRef.current.toFixed(2);
        setCurrentMultiplier(formattedMultiplier);
        if (typeof window !== "undefined") {
          localStorage.setItem("currentMultiplier", formattedMultiplier);
        }

        if (gameInterval.current) clearInterval(gameInterval.current);
        gameInterval.current = setInterval(() => {
          updateGraph();
        }, 50);
      } else {
        setGameState("waiting");
        startCountdown();
      }
    });

    newSocket.on("crash-update", (newCrashPoint) => {
      multiplierRef.current = parseFloat(newCrashPoint) || multiplierRef.current;
      updateGraph();
    });

    newSocket.on("updatehistory", (finalMultiplier) => {
      setGameState("crashed");
      setCrashPoint(parseFloat(finalMultiplier) || crashPoint);
      multiplierRef.current = parseFloat(finalMultiplier) || multiplierRef.current;
      if (gameInterval.current) {
        clearInterval(gameInterval.current);
      }
      updateGraph();
    });

    newSocket.on("reset", () => {
      resetGame();
    });

    return () => {
      if (gameInterval.current) {
        clearInterval(gameInterval.current);
      }
      newSocket.disconnect();
    };
  }, [resetGame, updateGraph, startCountdown]);

  // Calculate the dynamic y-axis max based on the highest value in dataPoints
  const calculateMaxYAxis = () => {
    const maxDataPoint = Math.max(...dataPoints);
    return maxDataPoint * 1.2; // Add a buffer to ensure the graph is not at the top
  };

  const data = {
    labels: timePoints,
    datasets: [
      {
        label: "",
        data: dataPoints,
        borderColor: "#24ee89",
        borderWidth: 5,
        pointRadius: (context: { dataIndex: number }) => {
          const index = context.dataIndex;
          return index === dataPoints.length - 1 ? 6 : 0;
        },
        pointBackgroundColor: (context: { dataIndex: number }) => {
          const index = context.dataIndex;
          return index === dataPoints.length - 1
            ? "rgb(68, 207, 137)"
            : "transparent";
        },
        fill: true,
        backgroundColor: (context: { chart: { ctx: CanvasRenderingContext2D } }) => {
          const ctx = context.chart.ctx;
          const gradient = ctx.createLinearGradient(213, 221, 232, 70);
          gradient.addColorStop(0, "rgb(213, 221, 232, 0.2)");
          gradient.addColorStop(1, "rgb(68, 207, 137,0.4)");
          return gradient;
        },
      },
    ],
  };

  const options: ChartOptions<"line"> = {
    responsive: true,
    maintainAspectRatio: false,
    animation: { duration: 0 },
    scales: {
      x: {
        type: "linear",
        position: "bottom",
        min: 0,
        max: timePoints.length > 0 ? Math.max(...timePoints) + 1 : 1,
        title: { display: true, text: "Time (s)" },
        ticks: {
          callback: (value) => `${Number(value).toFixed(1)}s`,
        },
        grid: { display: false },
      },
      y: {
        type: "linear",
        position: "left",
        min: 1,
        max: calculateMaxYAxis(), // Dynamic y-axis max value
        title: { display: true, text: "Multiplier (x)" },
        ticks: {
          callback: (value) => `${Number(value).toFixed(1)}x`,
        },
        grid: { display: false },
      },
    },
    plugins: {
      legend: { display: false },
      tooltip: { enabled: true },
    },
  };

  return (
    <div className="relative w-full h-[300px] sm:h-[300px] md:h-[330px] bg-[#1f1e1e] rounded-lg overflow-hidden font-poppins">
      <div className="absolute inset-0">
        <Line data={data} options={options} />
      </div>
      <div className="absolute inset-0 flex items-center justify-center mb-4">
        {gameState === "playing" && (
          <div className="text-3xl sm:text-5xl md:text-6xl font-extrabold text-white-400">
            {parseFloat(multiplierRef.current.toFixed(2))}
            <i
              style={{
                fontSize: "36px",
                lineHeight: "30px",
                fontWeight: 900,
              }}
              className="fa-sharp fa-solid fa-xmark fa-xl"
            ></i>
          </div>
        )}
        {gameState === "crashed" && (
          <div className="text-2xl sm:text-4xl md:text-6xl font-extrabold text-red-600">
            Crash at {crashPoint.toFixed(2)}x
          </div>
        )}
        {gameState === "waiting" && (
          <div className="text-white text-3xl sm:text-2xl md:text-4xl font-extrabold animate-pulse">
            Next round in {countdown}s
          </div>
        )}
      </div>
    </div>
  );
}

Original image
I want this type of graph, in which the x-axis and y-axis growing according to the multiplier value. If anyone can solve this problem, I will surely pay them.
“I’m building a graph where the x-axis (time) and y-axis (multiplier) grow according to the multiplier value. The current y-axis is not scaling correctly. How can I adjust the y-axis dynamically to fit the multiplier value? Need help!”

This explanation captures the issue and your need for a dynamic adjustment to the graph’s axes based on the multiplier value. Let me know if you need any more details!