Skip to content

Tag: javascript

D3 update color based on data

I’m drawing and coloring lines based on data with D3. I now want to update the color of these lines based on different features in the same data set but my color-changing function (colorP2) does not work–I know this color change looks useless, but it will later be triggered by a button. Any ideas?…

Push data into existing array using javascript

I am trying to find a way to build my custom array, but I am not able to do so. What I have done so far: I have my array constructed like so: const super_array = []; Further down into the code, I want to assign new data to the array, like so : Result: Right now, I get the

how to can i merge two functions into single function?

i want to make a table with JavaScript and i am fetching data from Api so i have created two function and i want to merge these functions in to single #output. my one function is fetch data from api and render out in table, second is fetch data from Api for filtering the data. index.js Answer Basically just d…

Jest: TypeError: replaceAll is not a function

String.prototype.replaceAll() is a useful method and while building and executing everything works fine. However, all Jest-tests fail with the following error: These are my dependencies: How can I fix this behavior? Answer The problem This happens because replaceAll is a new function not implemented in all br…

child elements usage in shadow dom

Is there any constraint that’s preventing <thead>, <tbody>, <tr> and so on to be slotted in shadow DOM? Given the following example: renders into the following structure: The workaround would be to use templates and insert template content with JS in slotchange event handler, but I wou…

Javascript countdown timer timezone problem

is it possible to have the countdown timer same for all people regardless of their timezone, when i put a date now the timer will show different depending on the timezone, and i want them to sync up so everyone get the same time, because now the “DONE” will display at different times depending on …

Does internet speed afect browser JavaScript?

I wanted to know if browser speed affects the execution time of JavaScript code. For example, if I have this code Does it mean that someone with a 4G connection will get this code executed earlier than someone with a 2G connection Answer No, as I understand it, Java Script is run in your browser and your brow…

Line chart not displaying from JSON Data

actually I am trying to make a chart line using D3.js. I made x axis and y axis but now the chart line is missing. here is my json data: filterData([ ` { “Sparte”: “Beherbergung”, “Jahr”: 2020, “Monat”: “Januar”, “Beschaeftigte”: “1…

get data from dropdown for dynamic call api

So I use redux-hooks for state management, so in my application there is a dropdown, the value will be used to call api dynamically, in the action creator I made it like this but i got this error how to get the value from the dropdown so that it can be entered into the action creator? is it possible? sorry