How do i make search bar appear and disappear upon clicking outside the appeared field in the page?

Working on adding search bar to my web page ,and on smaller screen there is search icon at the navbar , upon toggle it enables the search bar visibility in just below the navbar(first in the main content). Prior to this toggling the search icon in the navbar makes the search bar visible in just below the navbar,which is in the main content. There after clicking outside the search bar(input field) the search bar visibility is set to none . Now here is my issue encoutered ! When i toggle the search icon the search bar appears,so therefore any click outisde the search bar makes every content in the main content disappear ,which i want only the search bar visibility to be none excluding the rest. Below is my bootstrap codes

 ** Bootstrap codes**
<!------------------------------Main Content-------------------------->
<!-- Button trigger search panel . -->
<div class="container">
    <form action="GET" id="searchPanel">
        <div class="input-group mb-3 d-flex rounded-4" style="width:100%;" id="input">
           <div class="input-group-prepend">
               <span class="input-group-text d-block mx-auto"><i class="fa-solid fa-magnifying-glass" id="searchIcon"></i></span>
           </div>
           <input type="text" class="form-control" placeholder="Search for....">
           <button type="submit" class="btn btn-outline-success ">Search</button>
       </div>
      </form>
    </div>

JavaScript implementation

document.addEventListener('DOMContentLoaded', () => {
    const searchIcon= document.getElementById('search');
    const searchBar = document.getElementById('searchPanel');
    const searchInput = document.getElementById('input')
    //Toggle search bar visibility
    searchIcon.addEventListener('click', () => {
        if(window.innerWidth < 992) {
            searchBar.style.display = (searchBar.style.display === 'block') ? 'none' : 'block'
       }
   });
   //Hide search bar clicking outside appeared search bar
    document.addEventListener('click', (e) => {
        const clickInside = searchIcon.contains(e.target) || searchBar.contains(e.target);
        if(!clickInside) {
            searchBar.style.display = 'none';
        }
    });
})

vscode graying out unused variables doesn’t work without eslint in js files

Showing unused variables by dimming them is working for me in some files including json and … but not in js ones.
I have explicitly set editor.showUnused (Although apparently it’s working) and javascript.validate.enable to true value in settings.json as suggested in this answer and also tried setting js/ts.implicitProjectConfig.checkJs to true. Also I have checked builtin related extensions to be enabled but unused variables didn’t gray out in js files without enabling eslint.
I am using eslint in my project but I want to disable the no-unused-vars rule because It’s annoying while coding by throwing warnings until using the variables, but then the graying out doesn’t work again, so I want to use the vscode builtin validation.
Is there any way to diagnose the problem?

I need an aesthetical calendar iframe that can be customizable

I am making a website using HTML, CSS, and JS and I am trying to add a calendar into one of my pages, i’ve managed to put a google calendar iframe in there, but GOD it looks awful. Does anyone know any good (and aesthetical) calendar ifames that can be easily customizable?
This calendar needs to be able to hold event details for website users to view

I’ve tried the google calendar iframe, thinking it would have the same (good looking and sexy) pesentation, that you get using the app (I was so wrong) and the coustomizable features were very limited.

Are website builders a good alternative to common framework coding? [closed]

So hi there, i expect here to meet some people with website builder expirience that could clearly tell me where the limitations of website builders are at. I am thinking of switching from coding in react+nextjs to a website builder like framer. The problem is that i dont really know where the limitations are at. I would like to export the code and implement a backend by myself later on. Is that even possible ? And it in the best case it should also be free to export the code.

Ive looked thru some website builders but I just found webflow which sucks your soul out(pretty expansive)

jest scripts failing with exit status 1

I have a couple of test scripts that are failing after the tests are all passing successfully and not sure the reason. I’ve searched the web with no solution that resolves
the issue.

Here is the output from the log after the execution of the script (npm run patch-coverage)

0 info it worked if it ends with ok
1 verbose cli [
1 verbose cli   'C:\Program Files\nodejs\node.exe',
1 verbose cli   'C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js',
1 verbose cli   'run',
1 verbose cli   'patch-coverage'
1 verbose cli ]
2 info using [email protected]
3 info using [email protected]
4 verbose run-script [ 'prepatch-coverage', 'patch-coverage', 'postpatch-coverage' ]
5 info lifecycle [email protected]~prepatch-coverage: [email protected]
6 info lifecycle [email protected]~patch-coverage: [email protected]
7 verbose lifecycle [email protected]~patch-coverage: unsafe-perm in lifecycle true
8 verbose lifecycle [email protected]~patch-coverage: PATH: C:Program Filesnodejsnode_modulesnpmnode_modulesnpm-lifecyclenode-gyp-bin;C:<...>node_modules.bin;C:Python312Scripts;C:Python312;C:Program Files (x86)RSA SecurID Token Common;C:Program FilesRSA SecurID Token Common;C:windowssystem32;C:windows;C:windowsSystem32Wbem;C:windowsSystem32WindowsPowerShellv1.0;C:windowsSystem32OpenSSH;C:Program FilesMicrosoft SQL Server150ToolsBinn;C:Program FilesMicrosoft SQL ServerClient SDKODBC170ToolsBinn;C:Program Files (x86)Microsoft SQL Server150DTSBinn;C:Program FilesAzure Data Studiobin;C:Program FilesAmazonAWSSAMCLIbin;C:Program FilesMongoDBTools100bin;C:MongoSHmongosh-1.10.6-win32-x64binmongosh_crypt_v1.dll;C:Program FilesGitcmd;C:Program Filesdotnet;C:ProgramDatachocolateybin;C:Program Filesnodejs;C:Program FilesDockerDockerresourcesbin;C:Program FilesAmazonAWSCLIV2;C:UsersgnorkettAppDataLocalMicrosoftWindowsApps;C:Usersgnorkett.dotnettools;C:Program FilesAzure Data Studiobin;C:UsersgnorkettAppDataLocalProgramsFiddler;C:DevUtils;C:UsersgnorkettAppDataLocalProgramsMicrosoft VS Codebin;C:Program FilesAmazonAWSSAMCLI;c:terraform;c:terragrunt;C:UsersgnorkettAppDataLocalGitHubDesktopbin;C:Usersgnorkett.dotnettools;C:UsersgnorkettAppDataRoamingnpm
9 verbose lifecycle [email protected]~patch-coverage: CWD: <...>
10 silly lifecycle [email protected]~patch-coverage: Args: [ '-c', 'npm run patch-tests -- --coverage' ]
11 silly lifecycle [email protected]~patch-coverage: Returned: code: 1  signal: null
12 info lifecycle [email protected]~patch-coverage: Failed to exec patch-coverage script
13 verbose stack Error: [email protected] patch-coverage: `npm run patch-tests -- --coverage`
13 verbose stack Exit status 1
13 verbose stack     at EventEmitter.<anonymous> (C:Program Filesnodejsnode_modulesnpmnode_modulesnpm-lifecycleindex.js:332:16)
13 verbose stack     at EventEmitter.emit (events.js:400:28)
13 verbose stack     at ChildProcess.<anonymous> (C:Program Filesnodejsnode_modulesnpmnode_modulesnpm-lifecyclelibspawn.js:55:14)
13 verbose stack     at ChildProcess.emit (events.js:400:28)
13 verbose stack     at maybeClose (internal/child_process.js:1088:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:296:5)
14 verbose pkgid [email protected]
15 verbose cwd <...>
16 verbose Windows_NT 10.0.19045
17 verbose argv "C:\Program Files\nodejs\node.exe" "C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js" "run" "patch-coverage"
18 verbose node v14.21.3
19 verbose npm  v6.14.18
20 error code ELIFECYCLE
21 error errno 1
22 error [email protected] patch-coverage: `npm run patch-tests -- --coverage`
22 error Exit status 1
23 error Failed at the [email protected] patch-coverage script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]

All the tests are successful

Test Suites: 18 passed, 18 total
Tests:       74 passed, 74 total
Snapshots:   126 passed, 126 total
Time:        220.454 s, estimated 340 s
Ran all test suites.
Waiting for the debugger to disconnect...
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] patch-tests: `jest --config="./jest.config.patch.js" --runInBand --passWithNoTests "--coverage"`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] patch-tests script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     ...npm-cache_logs2024-01-31T20_58_41_359Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] patch-coverage: `npm run patch-tests -- --coverage`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] patch-coverage script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     ...npm-cache_logs2024-01-31T20_58_41_398Z-debug.log

This is the config file (jest.config.patch.js)

// For a detailed explanation regarding each configuration property, visit:
// https://jestjs.io/docs/en/configuration.html

const _ = require('lodash');

const config = _.cloneDeep(require('./jest.config.e2e'));

// The directory where Jest should output its coverage files
config.coverageDirectory = 'test_out/patch';

// reset collectCoverageFrom param to default value
config.collectCoverageFrom = ['resources/patch/patches/**/*.[jt]s'];

config.coveragePathIgnorePatterns = [];

// The glob patterns Jest uses to detect test files
config.testMatch = [
    '<rootDir>/resources/patch/**/__tests__/**/*.e2e.[jt]s',
    '<rootDir>/resources/patch/**/__tests__/**/*.spec.[jt]s',
];

// reset testPathIgnorePatterns param to default value
config.testPathIgnorePatterns = ['<rootDir>/node_modules/', '.tmp'];

config.moduleNameMapper['^resources(.*)$'] = '<rootDir>/resources$1';

config.coverageThreshold = {
    global: {
        branches: 100,
        functions: 100,
        lines: 100,
    },
};

module.exports = config;

I’ve tried a few suggestions from GitHub

Can anyone provide a solution to resolve the errors?

Note: <…> is a place holder for some potential restricted information as deemed by the company.

Updating the like count in Firebase real time database

I have a function where I post an image, like, and comment in the react-native app but hosted in Firebase real-time database all these elements are within a single post, now I want to update the post when a user presses the like icon to reflect in the app and in firebase to have 1 or any number.

export const Likes = ({ postId, initialLikes, likes }) => {
  const { countingLikes, setCountingLikes } = usePostContext();
  const {user} = useAuthContext()
  const [isLiked, setIsLiked] = React.useState(false); // Manage likes for each post separately

  const theme = useThemeContext();

  const ChangeLikesColor = async () => {
    try {
      // Toggle isLiked state
      const newIsLiked = !isLiked;
      setIsLiked(newIsLiked);
  
      // Update local likes count
      setCountingLikes(newIsLiked ? countingLikes + 1 : countingLikes - 1);
  
      // Update likes in Firebase
      await updateLikesForPost(postId, newIsLiked);
    } catch (error) {
      console.error('Error updating likes:', error);
      // Revert local state changes if update fails
    }
  }
  // // Function to update likes for a specific post in Firebase
  const updateLikesForPost = async (postId, isLiked) => {
    try {
      const postRef = database.ref(`Posts/${user.uid}`);
  
      // Fetch the current likes count from Firebase
      const snapshot = await postRef.once('value');
      const data = snapshot.val();
  
      //find and retrieve the post Id and likes count
      if (data) {
        const posts = Object.entries(data).map(([postId, item]) => ({
          postId,
          likes: item.likes ,
        }))
        console.log(posts)
        
      } else {
        console.error('Post data not found.');
      }
    } catch (error) {
      console.error('Error updating likes:', error);
    }
  }

  React.useEffect(() => {
    // Initialize the isLiked state based on the initialLikes prop
    setIsLiked(initialLikes > 0);
  }, [initialLikes]);

  return (
    <>
      <View style={[LikesStyle.likeOverAllContainer, { backgroundColor: theme.likes.likeOverAllContainerBackgroundColor }]}>
        <View activeOpacity={changeOpacity} style={[LikesStyle.likesContainer, {}]}>

          <Tch onPress={ChangeLikesColor}>
            {/* Change the heart icon color based on the isLiked state */}
            <MatIcon
              name={isLiked ? "heart" : "heart-outline"}
              size={28}
              style={[
                LikesStyle.likesIcon,
                { color: isLiked ? theme.likes.likeIconColor : theme.likes.blankHeart },
              ]}
            />
          </Tch>

          <Text style={[LikesStyle.likes, { color: theme.likes.likeTextColor }]}>Likes</Text>
          {/* Display the likes count from the static data or show 0 if likes is undefined or null */}
          <Text style={[LikesStyle.likes, { color: theme.likes.likeCountColor }]}>
            {likes !== undefined && likes !== null ? likes : 0}
          </Text>
        </View>
      </View>
    </>
  );
};

and this is how I access it in other components

<Likes postId={post.postId || post.id} initialLikes={post.likes} likes={post.likes} />

Here’s my structure in firebase
Posts/userId/postId then after that I have post elements like
[
caption,comments,image,likes,time
]

I tried various ways to implement this but failed.

const updateLikesForPost = async (postId, isLiked) => {
  try {
    const userRef = database.ref(`Posts/${user.uid}`);

    // Fetch the current post data from Firebase
    const snapshot = await userRef.once('value');
    const data = snapshot.val();

    console.log('Fetched data:', data);

    // Check if the post exists in the data
    if (data && data[postId]) {
      console.log('Post data found:', data[postId]);

      // Update the likes count for the specific post
      const updatedLikes = isLiked ? data[postId].likes + 1 : data[postId].likes - 1;

      // Update likes for the specific post in the local state
      setPostUrls(prevUrls => {
        const updatedPosts = prevUrls.map(post => {
          if (post.postId === postId) {
            return {
              ...post,
              likes: updatedLikes
            };
          }
          return post;
        });
        return updatedPosts;
      });

      // Update likes count in Firebase
      const postRef = userRef.child(postId);
      await postRef.update({ likes: updatedLikes });

      console.log('Likes updated successfully.');
    } else {
      console.error('Post data not found.');
    }
  } catch (error) {
    console.error('Error updating likes:', error);
  }
};

What I want to achieve is to have a successful update on the like component both reflected in firebase and in the app.

How to make sure my object list of users follows the Columns list of a react table

Hi everyone, I’d like to talk to you about what I’m trying to do. In short, I created an HTML table using React by dividing the Table.js into itself with two components such as:
StaffColumns.js
StaffData.js
Inside these two we have functions with passed props that is:

StaffData.js

//utentiLista it's my list of objects inside an Array called "utentiLista"
const StaffDati = ({utentiLista}) => {
    
  const styleText = {
    backgroundColor: '#1F2A37',
    textAlign: 'left',
    padding:'10px 10px 10px 10px',
    color: 'var(--primary-text)',
    paddingLeft: '10px',
    borderTop: '1px solid #343E4E',
    borderBottom: '1px solid #343E4E',
  }


    const getStatusStyle = (status) => {
        switch (status) {
          case 'Completed':
            return ({ color: 'lightgreen',
                      src: check
            });
          case 'Pending':
            return { color: 'yellow',
                      src: hour
          };
          case 'In progress':
            return { color: '#A992F6',
                      src: cloud
          };
          default:
            return {};
        }
      };
      
    return (
        <tbody style={{width:'100%'}}>
      {//! la lista utenti viene passata come props a Tabella e poi fatto un mapping proprio come in Sidebar.js
      
      utentiLista.map((utente, index) => (
        
      <tr key={utente.id} style={{width:'100%'}}>
        <td style={{...styleText, borderLeft: index === -1  ? 'none' : '1px solid #343E4E'}}>{utente.id}</td>
        <td style={styleText}>{utente.username}</td>
        <td style={styleText}>{utente.data}</td>
        <td style={styleText}>{utente.amount}€</td>
        <td style={{...styleText, borderRight: index === utentiLista.length  ? 'none' : '1px solid #343E4E' }}>

          <div style={{color: getStatusStyle(utente.status).color, 
                       width: 'fit-content', 
                       padding:'5px', 
                       border:`1px solid ${getStatusStyle(utente.status).color}`, 
                       borderRadius: '10px', 
                       fontSize: '10px',
                       backgroundColor: '#374151',
                       display: 'flex',
                       flexDirection: 'row', 
                       flexWrap: 'no-wrap',
                       alignContent: 'center', 
                       gap: '5px'}}>
                        <img src={getStatusStyle(utente.status).src} alt="" />
          {utente.status}
          </div>
          </td>
      
      </tr>
      ))}
    </tbody>
    )
    
}

export default StaffDati; 

My StaffColumns instead have this code:

import React, {useState, useTransition } from "react"
const ColoneStaff = ({utentiLista, setUtentiLista}) => {
    
    const styleTr = {
        backgroundColor: '#374151',
        color: 'var(--primary-text)',
        textAlign: 'left',
      }
      const styleTh = {
        backgroundColor: '#374151',
        color: 'var(--primary-text)',
        textAlign: 'left',
        padding: '20px 0px 20px 10px',
        cursor: 'pointer',
      };
      const [staffColumns, setStaffColumns] = useState([
        {
        name: 'ID',
        field: 'id',
        type: 'number',
        style: styleTh,
        ascending: true,
        isSortable: true,
      },
      {
          name: 'Username',
          field: 'username',
          type: 'string',
          style: styleTh,
          ascending: true,
          isSortable: true,
      },
      {
          name: 'Data',
          field: 'data',
          type: 'string',
          style: styleTh,
          ascending: true,
          isSortable: false,
      },
      {
          name: 'Amount',
          field: 'amount',
          type: 'number',
          style: styleTh,
          ascending: true,
          isSortable: true,
      },
      {
          name: 'Status',
          field: 'status',
          type: 'string',
          style: styleTh,
          ascending: true,
          isSortable: true,
      },
      {
        name: 'Action',
        field: 'action',
        type: 'string',
        style: styleTh,
        ascending: true,
        isSortable: false,
      }
      
    ]);
    const handleSort = (field) => {
      const sortingColumn = staffColumns.find((column) => column.field === field);
      if (field) {
        const updatedColumns = staffColumns.map((column) => {
          if (column.field === field && column.isSortable) {
            column.ascending = !column.ascending;
          }
          return column;
        });
  
        setStaffColumns(updatedColumns);
  
        const sortedList = [...utentiLista].sort((a, b) => {
          const aValue = a[field];
          const bValue = b[field];
          if(sortingColumn.type === 'number'){
          return sortingColumn.ascending ? aValue - bValue : bValue - aValue;
        }else{
          return sortingColumn.ascending
            ? String(aValue).localeCompare(String(bValue))
            : String(bValue).localeCompare(String(aValue));
        }
        });
        setUtentiLista(sortedList);
      }
    };

    return (
        <thead>
 <tr style={{...styleTr}}>

        {staffColumns.map((column) =>  {
            return(
             <th key={column.field} onClick={() =>handleSort(column.field)} style={column.style}>
             {column.name}
            </th>  
            )
        })
    }
     </tr>
    </thead>
    )
}
export default ColoneStaff;

Now my question it’s pretty simple, how can I check if my utentiLista.keys are equal to my StaffColumns list. Inside StaffColumns I created an object that has no properties of the usersList object and therefore does not print anything in the table data but simply prints the empty Column. This is the {name:'Action'} object.
I would like to be able to find the “intruder” object in my columnStaff list, and not delete it but every time a column like that of ‘Action’ is added and which does not correspond to any value of the usersList object, and which then go and print a simple “in the data of that column Action”.
<td>Missing Value</td>
This is my usersList array:

  const [utentiLista, setUtentiLista] = useState([
    {id: 1, username: 'FEDERICOSCHI', data: '...', amount: 2000, status: 'Completed'},
    {id: 2, username: 'Feryzz', data: '...', amount: 15, status: 'Completed'},
    {id: 3, username: 'Cinquanta', data: '...', amount: 27, status: 'Pending'},
    {id: 4, username: 'NotAffected', data: '...', amount: 50, status: 'In progress'},
    {id: 5, username: 'Ytnoos', data: '...', amount: 12, status: 'Completed'},
    {id: 6, username: 'Mattia882', data: '...', amount: 33, status: 'In progress'}
  ]);

Express doesn’t load static files from the public folder in routes with multiple parameters

I’m trying to render a page, but the static files are not being loaded by Express only on routes with a single parameter

Static configuration:
app.use(express.static(path.resolve(__dirname, "public")));

Route:
routes.get("/param/:id", (req, res) => res.render("page"));

Error:

Failed to load resource: the server responded with a status of 404 (Not Found)

Refused to execute script from 'http://localhost:port/param/1/assets/js/bundle.js' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled.

I’ve tried everything; maybe it has something to do with the structure of my project?

Repo: projeto-agenda

Create player radio for Azuracast

I’m part of a radio association and I’m planning to replace the radio’s current player, as the current one only plays the station’s music on the website.

I’m new to coding, my specialty being networking. I spent several hours trying to figure out how to update the image, artist and title of the music on this player. I noticed that there are APIs, so I ran a few tests but only managed to change the source to listen to the radio.

I retrieved the player’s code from [https://codepen.io/qobalt/pen/abZddNd][1] and tried to adapt it to carry out the actions I mentioned earlier, as it works perfectly for Radio King, but it’s impossible for me to achieve what I want, given my limited programming skills, I tried to put Azuracast’s API links but without success.

Could someone help me adapt the code for Azuracast?
Thank you for your help.

I’d like someone to help me create this radio player, as my programming skills are poor.

Integrating Geolocation Libraries and Handling CSV Data in a Node.js Web Application

As part of a project, we are retrieving a list of coordinates between two geographical points. We would like, from this large table of coordinates, to obtain for each of them the nearest unique city. For this, we have a .csv file containing all the municipalities in France with their respective coordinates. Locally, we have a function that does exactly what we just described, and it works well. The idea is to visualize the results on a web application.

The problem arises when we deploy our NodeJs project (localhost:3000) => we receive errors of the type “Uncaught ReferenceError: require is not defined.” Indeed, these libraries are not accessible on the front end. We found one that could help us in our project, namely Geolib (https://www.npmjs.com/package/geolib). However, we can’t use it, whether locally or by inserting the script tag in the index.html file.

How do we use libraries once the code is deployed? How can I read the data from my csv file locally, in my browser? Should I host this file somewhere other than locally? Our project is in NodeJs with an Express server.

Thank you!

I tried to add the librairy const geolib = require('geolib');
, using import { getDistance } from ‘geolib’;
, and added the
tag in my html files. Neither of them were working.

Searching in input

I’m having trouble searching. I have an array with customers, I want to search by name. Initially, everything works fine, but when I use backspace, the names do not update. Does not display the initial data from the array.

 const[searchCustomer, setSearchCustomer] = useState('')
 const changeSearchCustomer = (e) => {
  setSearchCustomer(e.target.value);
};
 const searchingCustomer = (e) =>{
  let costumers = [...customers];
  costumers = costumers.filter((el) =>
  
    el.firstName
      .toLowerCase()
      .includes(searchCustomer.toLowerCase())
  );

  setCustomers(costumers)

 }
<input type="text" placeholder="search..." value={searchCustomer} onChange={changeSearchCustomer} onKeyUp={searchingCustomer} />

Does not display the initial data from the array.

next/navigation Error 404 dynamic routes only in production NEXT13

Hello everybody i have a problem using NEXT’s dynamic routing (Next 13)
I have this structurr

- user/
-- [id]/
--- page.js

and this is working on dev mode but not in prod.

What im trying?

Im make a “page.js” inside user folder with this config on it

export const dynamic = 'auto'
export const dynamicParams = true
export const revalidate = false
export const fetchCache = 'auto'
export const runtime = 'nodejs'
export const preferredRegion = 'auto'
export const maxDuration = 5
 
export default function MyComponent() {}

I not using “generateStaticParams” because the param is generated randomly on backend and sended to user email.

there are any way to solve this? Thanks for the answers

My buttons are in a class, how do I use if statement based on id? [duplicate]

I have a set of buttons in a class, and I’m trying to run a function so a piece of HTML will change based on what button was pressed. How would I use if/else statement to change the outcome based on the id of the button?

document.querySelector(".pizza").addEventListener('click', function(){
  if (document.getElementById("small").clicked == true) {
    Size_Price = 5;
    document.getElementById("head1").textContent = "Small";
  } else if (document.getElementById("medium").clicked == true) {
    Size_Price = 10;
    document.getElementById("head1").textContent = "Medium";
  }
})

This is what I’ve tried, to no avail.

amcharts create only 3 series from combo data

I have this function in amcharts4 that creates a series for each year of data, is there a way to put a combo so that only 3 series can be put on the graph but in each combo say which years to show? I have more than 10 years of data and I don’t want to put it all on the graph
I use php and javascript. I get data from a json.

chart.dataSource.url = "ejemplodatos.php";

Thanks

function createAxisAndSeries(field, name, opposite, bullet) {
  var valueAxis = chart.yAxes.push(new am4charts.ValueAxis());
  if(chart.yAxes.indexOf(valueAxis) != 0){
    valueAxis.syncWithAxis = chart.yAxes.getIndex(0);
  }
  var series = chart.series.push(new am4charts.LineSeries());
  series.dataFields.valueY = field;
  series.dataFields.categoryX = "mesdia";
  series.strokeWidth = 2;
  
  series.name = name;
  series.tooltipText = "{name}: [bold]{valueY}[/]";
  series.minBulletDistance = 10;
  //series.disabled=true 
  var interfaceColors = new am4core.InterfaceColorSet();
  
  switch(bullet) {
    case "triangle":
      valueAxis.renderer.line.disabled = true; //disables axis line
      valueAxis.renderer.labels.template.disabled = true; //disables labels
      valueAxis.renderer.grid.template.disabled = true;  //disables grid
      var bullet = series.bullets.push(new am4charts.Bullet());
      bullet.width = 1;
      bullet.height = 1;
      bullet.horizontalCenter = "middle";
      bullet.verticalCenter = "middle";
      
      var triangle = bullet.createChild(am4core.Triangle);
      triangle.stroke = interfaceColors.getFor("background");
      triangle.strokeWidth = 2;
      triangle.direction = "top";
      triangle.width = 1;
      triangle.height = 1;
      break;
 
    default:
      var bullet = series.bullets.push(new am4charts.CircleBullet());
      bullet.circle.stroke = interfaceColors.getFor("background");
      bullet.width = 1;
      bullet.height = 1;
      bullet.circle.strokeWidth = 2;
      break;
  }
  
  valueAxis.renderer.line.strokeOpacity = 1;
  valueAxis.renderer.line.strokeWidth = 2;
  valueAxis.renderer.line.stroke = series.stroke;
  valueAxis.renderer.labels.template.fill = series.stroke;
  valueAxis.renderer.opposite = opposite;
  valueAxis.renderer.grid.template.disabled = true;
}
createAxisAndSeries("a2024", "2024", false, "default");
createAxisAndSeries("a2023", "2023", false, "default");


function toggleAxes(ev) {
  var axis = ev.target.yAxis;
  var disabled = true;
  axis.series.each(function(series) {
    if (!series.isHiding && !series.isHidden) {
      disabled = false;
    }
  });
  axis.disabled = disabled;
}