Is it possible to make a multi-color highlight arc in Sigma.js?

I’m trying to implement my own hoverRenderer to make the highlight ring have multiple colors. So I took the drawHover in src/rendering/canvas/hover.ts line 58 and replaced

context.arc(data.x, data.y, data.size + PADDING, 0, Math.PI * 2);
context.closePath();
context.fill();

with

        const [fillStart, fillEnd, fillRadius] = [0, Math.PI * 2, data.size + PADDING];
        // compute segment arc radian
        const arcRadian = (fillEnd - fillStart) / data.highlightColor.length;

        // draw the highlight ring/arc in different colors specified in highlightColor
        for (let index = 0; index < data.highlightColor.length; index++) {
            context.arc(
                data.x,
                data.y,
                fillRadius + 5,
                fillStart,
                fillStart + arcRadian
            );
            context.fillStyle = data.highlightColor[index];
            context.fill();
            fillStart += arcRadian;
        }
        context.closePath();

Even though my data.highlightColor was set to ['#FF2301', '#D53032', '#2F4538'], the arc I got was still single colored. This post has a similar implementation and achieves the effect I want. Is there any restriction imposed by Sigma that prevents this?

enter image description here

Google Pie Chart not show in Blade Laravel

I am trying to display the data with google pie chart. Everything works normally when running on localhost, but not in hosting. I’ve debugged and no errors were found. I am using Laravel 8.83.16

My Controller

public function index()
    {
        $dealers = Dealer::paginate(20);
        $count_dealers = DB::table('dealer_gesits')->count();

        $data_dealer = Dealer::select(
                DB::raw('province as province'),
                DB::raw('count(*) as number')
            )
            ->groupBy('province')
            ->get();
        $array[] = ['Province', 'Number'];
        foreach ($data_dealer as $key => $value) {
            $array[++$key] = [$value->province, $value->number];
        }

        if(request('search')){
            $dealers = Dealer::where('dealer_name', 'like', '%'.request('search').'%')
            ->orWhere('address', 'like', '%'.request('search').'%')->paginate(20);
        }

        $user       = Customer::latest()->get();

        // dd(json_encode($array));
        return view('dashboard.dealer.index', compact('dealers', 'count_dealers','user'))
            ->with('course', json_encode($array));
    }

My Blade View

<div class="card-body">
   <div id="pie_dealer" style="height: 300px;"></div>
</div>

<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<script type="text/javascript">
    var analytics = <?php echo $course; ?>

    google.charts.load('current', {'packages': ['corechart']});
    google.charts.setOnLoadCallback(drawChart);

    function drawChart() {
        var data = google.visualization.arrayToDataTable(analytics);
        var options = {
            title: 'Presentase Persebaran',
            pieHole: 0.4,
            style: {
                font: 'bold 15px "Open Sans", sans-serif'
            }
        };
        var chart = new google.visualization.PieChart(document.getElementById('pie_dealer'));
        chart.draw(data, options);
    }
</script>

Showing in Localhost
Pie chart showing in localhost

Not Showing in Hosting
Pie chart not showing in hosting

Here my console
All data has been received, but did not succeed in making a chart
All data received, but not making chart

Tailwind Browserslist not working in macos bigsur safari browser version 14.1

I have landing page issue when opening in Safari BigSur browser version 14.1

there are some classes from tailwind that don’t work

I’ve added autoprefixer and browserslist but still no change

"name": "01",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "browserslist": [
    "Chrome > 61",
    "Edge > 16",
    "Firefox > 60",
    "Safari > 10.1"
  ],
"dependencies": {
    "browserslist": "^4.20.4",
    "i18next": "^21.8.3",
    "swiper": "^8.1.4"
  }

is there any other way so tailwind can support in all browsers?

Authentication Error when trying to retrieve Youtube Chanel Information

I am trying authenticate the user and then retrieve youtube channel list.

Below is the function to authenticate:

function authenticate() {
  showNewLoader('show');
  return gapi.auth2.getAuthInstance()
  .signIn({scope: "https://www.googleapis.com/auth/youtube.readonly"})
  .then(function(response) {  
    console.log( response);
    youtubeAuthResponse['token_details'] = response.tc; 
    youtubeAuthResponse['google_email'] = '';
    youtubeAuthResponse['google_id'] = '';
    showNewLoader('hide');
  },
  function(err) { console.error("Error signing in", err); showNewLoader('hide');});
}

Loading client:

function loadClient() {
  showNewLoader('show');
  gapi.client.setApiKey("XXXXXX");
  return gapi.client.load("https://www.googleapis.com/discovery/v1/apis/youtube/v3/rest")
  .then(function() { execute();},
    function(err) { console.error("Error loading GAPI client for API", err);showNewLoader('hide');});
}

/*Make sure the client is loaded and sign-in is complete before calling this method.*/
function execute() {
  return gapi.client.youtube.channels.list({
    "part": [
    "snippet",
    "statistics"
    ],
    "mine": true
  })
  .then(function(response) {
    /*Handle the results here (response.result has the parsed body).*/
    youtubeChannelResponse = response.result;
    storeYoutubeData();
  },
  function(err) { console.error("Execute error", err); showNewLoader('hide') }).then(function(){
  });
}

User logs in successfully but I am unable to get the channel info:

enter image description here

Any assistance on this issue is greatly appreciated. @DalmTo

Image not visible. HTML and Javascript

I am pretty new to using canvas’ and images, and wanted to start making a little game. I just wanted to start off with being able to move the image around. I got that to work no problem. Then when I wanted to add collision, things started too…go in the opposite direction. All of a sudden my ‘sprite’ started to not show but I knew my my collision code was working thanks to logging it into the console. Does anyone know what is happening?

HTML:

<html>

<head>
</head>
<script src="JavaScript.js"></script>

<body onkeydown="getKeyAndMove(event)">
    <canvas id="gameWindow"></canvas>
    <img id="playerSprite" src="fdffsefse"/>
</body>

</html>

JS:

function onStart() {
    //Game Window
    var gameWindow = document.getElementById("gameWindow");
    gameWindow.style.position = "absolute"
    gameWindow.style.width = "650px";
    gameWindow.style.height = "340px";
    gameWindow.style.border = "solid #000000";
    gameWindow.style.backgroundColor = "black";
    //player
    playerSprite.style.left = "320px";
    playerSprite.style.top = "-170px";
}


let leftno = false;
let rightno = false;
let upno = false;
let downno = false;

function Sleep(ms) {
    return new Promise(resolve => setTimeout(resolve, ms));
}

function getKeyAndMove(e) {
    var key_code = e.which || e.keyCode;
    switch (key_code) {
        case 37: //left arrow key
            moveLeft();
            break;
        case 38: //Up arrow key
            moveUp();
            break;
        case 39: //right arrow key
            moveRight();
            break;
        case 40: //down arrow key
            moveDown();

            break;
    }
}

function moveLeft() {
    //checks if the border is right next to them. If so prevents them from crossing.
    if (leftno) {
        return;
    }
    playerSprite.style.left = parseInt(playerSprite.style.left) - 5 + "px";
    console.log("x axis " + parseInt(playerSprite.style.left));
    if (parseInt(playerSprite.style.left) == 0) {
        console.log("You have reached the border.")
        //since they are at the border this make sure they cannot pass. In other words collision!
        leftno = !leftno;
    }
    //basically checks if player is next to border. If so and they try to move left it'll then allow them to move right agian.
    if (rightno) {
        rightno = !rightno;
    }
}

function moveUp() {
    //checks if the border is right above them. If so prevents them from crossing.
    if (upno) {
        return;
    }
    playerSprite.style.top = parseInt(playerSprite.style.top) - 5 + "px";
    console.log("y axis " + parseInt(playerSprite.style.top));
    if (parseInt(playerSprite.style.top) == -350) {
        console.log("You have reached the border!");
        //since they are at the border this make sure they cannot pass. In other words collision!
        upno = !upno;
    }
    //basically checks if player is right above. If so and they try to move up it'll then allow them to move down agian.
    if (downno) {
        downno = !downno;
    }
}

function moveRight() {
    //checks if the border is right next to them. If so prevents them from crossing.
    if (rightno) {
        return;
    }
    playerSprite.style.left = parseInt(playerSprite.style.left) + 5 + "px";
    console.log("x axis " + parseInt(playerSprite.style.left));
    if (parseInt(playerSprite.style.left) == 640) {
        console.log("You have reached the border!");
        //since they are at the border this make sure they cannot pass. In other words collision!
        rightno = !rightno;
    }
    //basically checks if player is next to border. If so and they try to move right it'll then allow them to move left agian.
    if (leftno) {
        leftno = !leftno;
    }
}

function moveDown() {
    //checks if the border is right under them. If so prevents them from crossing.
    if (downno) {
        return;
    }
    playerSprite.style.top = parseInt(playerSprite.style.top) + 5 + "px";
    console.log("y axis " + parseInt(playerSprite.style.top));
    if (parseInt(playerSprite.style.top) == -20) {
        console.log("You have reached the border!");
        //since they are at the border this make sure they cannot pass. In other words collision!
        downno = !downno;
    }
    //basically checks if player is right under. If so and they try to move down it'll then allow them to move up agian.
    if (upno) {
        upno = !upno;
    }
}
window.onload = onStart;

Sorry about the mess 😐

Get options sent to pug with space in the name

I am trying to send JSON options into a pug file with a space in the attribute names.

For example, inside an express get request:

let json = {"Attribute Name With Spaces": "Value"}
res.render('loader.pug', json);

How do I access this data in the pug file? It is difficult to change the format of the json because it is external and not something I made myself.

React onMouseEnter and onMouseLeave bug, not working consistently

I am having issues with React onMouseEnter and onMouseLeave, sometimes the events are not firing when it should

I am using onMouseEnter and onMouseLeave to show/hide a React Portal Modal tooltip panel:

enter image description here

enter image description here

the issue:

if the mouse cursor hovers over the images slowly, onMouseEnter and onMouseLeave works as expected, but if the mouse cursor hovers over the image rapidly ( horizontally ), the code breaks, and multiple tooltip panels are shown ( because onMouseLeave failed to trigger )

here is the video link showing the issue:
https://www.veed.io/view/7669d6c4-6b18-4251-b3be-a3fde8a53d54?sharingWidget=true

here is the codesandbox link for bug I mentioned:
https://codesandbox.io/s/epic-satoshi-rjk38e

any help is appreciated

Painless Script to get Time difference

Hi I have 2 columns as date datatype in my Kibana Index Pattern and I want to add a third column as the difference between the 2 columns:
Here is sample and format of the columns:

Col1: Jun 16, 2022 , 09:00:00.000
Col2: Jun 16, 2022 , 09:10:07.999

Now I want to have a third column as TimeDifference in the following format:

TimeDiff: 00:10:07.999

Can anyone help me with the script please I tried a few but everytime it complains about invalid script, here is the script that I tried and it failed:

def diffInMs = doc['col2'].value.getMillis() - doc['col1'].value.getMillis();
def duration = Duration.ofMillis(diffInMs);
def hours = duration.toHours();
def minutes = duration.minusHours(hours).toMinutes();
def seconds = duration.minusHours(hours).minusMinutes(minutes).getSeconds();
def str = hours + ':' + minutes + ':' + seconds;
return str;

It would be really helpful if anyone could point out what did I miss out in this script.
Thanks

When I convert a React App to ES6, I got Module Not found error, how can I fix it?

My react application working properly.
However, I want to convert the application to ES6 format. So, I added "type": "module" to the package.json file.

When I had restarted the application, I got the following error message:

ERROR in ./src/index.js 8:0-24
Module not found: Error: Can’t resolve ‘./App’ in ‘D:workspacenewAppsrc’
Did you mean ‘App.js’?
BREAKING CHANGE: The request ‘./App’ failed to resolve only because it was resolved as fully specified
(probably because the origin is strict EcmaScript Module, e. g. a module with javascript mimetype, a ‘.mjs’ file, or a ‘.js’ file where the package.json contains ‘”type”: “module”‘).
The extension in the request is mandatory for it to be fully specified.
Add the extension to the request.

Is it possible to fix the problem without changing my source code?

According to the solution, it can be solved by changing the webpack.config.js content.

In the newAppnode_modulesreact-scriptsconfigwebpack.config.js, I found the following:

extensions: paths.moduleFileExtensions
    .map(ext => `.${ext}`)
    .filter(ext => useTypeScript || !ext.includes('ts')),

where paths.moduleFileExtensions = [ 'web.mjs', 'mjs', 'web.js', 'js', 'web.ts', 'ts', 'web.tsx', 'tsx', 'json', 'web.jsx', 'jsx', ];

It seems like the js extension has been added.
So, I don’t know how to fix the problem.

Here is my package.json for your reference.

      {
        "name": "itsqm",
        "version": "0.1.0",
        "private": true,
        "type": "module",
        "dependencies": {
          "@testing-library/jest-dom": "^5.16.1",
          "@testing-library/react": "^11.2.7",
          "@testing-library/user-event": "^12.8.3",
          "axios": "^0.25.0",
          "bootstrap": "^5.1.3",
          "cross-env": "^7.0.3",
          "dotenv-flow": "^3.2.0",
          "http-proxy-middleware": "^2.0.1",
          "node-fetch": "^2.6.7",
          "nodemon": "^2.0.15",
          "npm-run-all": "^4.1.5",
          "react": "^17.0.2",
          "react-bootstrap": "^2.0.3",
          "react-dom": "^17.0.2",
          "react-router-dom": "^6.0.2",
          "react-scripts": "^5.0.0",
          "react-select": "^5.2.1",
          "web-vitals": "^1.1.2"
        },
        "scripts": {
          "build": "react-scripts build",
          "dev": "cross-env NODE_ENV=development run-p server start",
          "prod": "cross-env NODE_ENV=production npm run server",
          "server": "nodemon -r dotenv/config ./server/index.js",
          "start": "react-scripts start",
          "test": "react-scripts test",
          "eject": "react-scripts eject"
        },
        "eslintConfig": {
          "extends": [
            "react-app",
            "react-app/jest"
          ]
        },
        "browserslist": {
          "production": [
            ">0.2%",
            "not dead",
            "not op_mini all"
          ],
          "development": [
            "last 1 chrome version",
            "last 1 firefox version",
            "last 1 safari version"
          ]
        }
      }

assign File into object property node js

im currently migrating some Frontend implementation into backend,
so in frontend im able to use:

const myFile = require('../random.json'); 

const aux =  new File (
             [myFile],
             "name.json",
             {type: "application/json"}
             );
const myObject = { myKey: aux }

I’m trying to do the same in nodejs app,
but I’m not able to use File, so it seems that I need to use:

const fs = require('fs');

reading the documentation maybe in my confusion I couldn’t find any method to accomplish the same behavior implemented previously used in a frontend application

so, how can I achieve this? do something similar to create a new file, and this instance assign as a value of a key in my current object (example above)

thank you in advance!

How to find a string and its location in an array [duplicate]

I have an array and a function to find if there is a specific string inside of it.
An example of the items I might have in the array are as follows:

var p1cards = ["R0", "Y7", "G5", "B9", "WI",]

The script I’m using to find the item I want is as follows:

cardin = ci.value;
// an input value
var cardinpresent = (p1cards.indexOf(cardin) > -1);

What I want to know is if there is a way to, in addition to seeing if the string is there, find the location of the string in the array.

SSRS open file link in new tab or window

I have a few reports that show a link to invoices (.pdf files) that are held on our network share.

I use this on the text box property to to action to allow the user to click on it and view the invoice:

="javascript:void(window.open('file:"+Fields!invoice_link.Value+"','_blank'))"

When the report is running, I can hover over the link and the correct link address is displayed in Chrome and Edge :

Hover link

When I click on the link, both EDGE and CHROME do nothing. When I right click and select open in new tab / window – it get this :

enter image description here

This works fine as expected in Internet Explorer – but this is no longer an option.

Things I’ve done so far :

  • I have allowed popup in both browsers

  • I have added the reportserver site as trusted site in security settings

  • I have added extensions that allow Local file links in the browser

  • I have allowed javascipt to run

Nothing seems to make any difference in opening the link.

I have confirmed that the file that the invoice_link field resolves to is available and accessible.

Does anyone have any other ideas? I can’t seem to find anything other than the javascript option to open files

Should I use action or mutation to update my state

I’m working on a small application using Vuex I would like to change my state data, my question is should I do that directly in my axios calls by calling a Vuex action or Vuex mutation ?

this is my code :

axios.get('http://test.com').then(response => {
            // should I use action like that  
            this.$store.dispatch('updateTableData', response.data)
            // Or mutation
            this.$store.commit('UPDATE_TABLE_DATA', response);
        });

which one should I use normally
Thank you

Toggle Search Input Autofocus

I am running a script when the search icon is clicked the search input is displayed with toggle but I cannot get this running so that the input autofocus is active so the user can type straight into the search box

    $(document).ready( function(){ 
         $("#velaSearchTop").each( function(){
            $("#velaSearchIcon").click( function(){
                 $("#velaSearchbox").toggleClass("show");
             });
            $(".btn-close").click( function(){
                 $("#velaSearchbox").removeClass("show");
             });
         }); 
    });
</script>


<div id="velaSearchTop">
    <span id="velaSearchIcon" class="fa fa-search"></span>
    <form id="velaSearchbox" class="formSearch" action="/search" method="get">
        <input type="hidden" name="type" value="product">
        <input class="velaSearch form-control" class="test" type="search" name="q" value="{{ search.terms | escape }}" placeholder="{{ 'general.search.placeholder' | t }}" autofocus />
        <button id="velaSearchButton" class="btnVelaSearch" type="submit" >
            <span><i class="fa fa-search"></i></span>
            <span class="btnSearchText">{{ 'general.search.submit' | t }}</span>
        </button>
        <div class="btn-close"><span class="fa fa-close"></span></div>
    </form>
</div>```

How do you replace and save documents in MongoDB?

I currently have a database that holds 5 entries per document in my mongoDB. Here is an example

I would like to update my documents in my database with more fields and information. Currently I am doing that with the code below.

    NFT.findOne({ "name": name }, (err, value) => {
        if (err) { console.error(err) }
        if (!value) {
            console.log('no value')
            let newNFT = new NFT({name, slug, symbol, description, verifiedStatus, bannerUrl, logoUrl, floorPrice, stats, social})
            newNFT.save() 
        } 
        else {
            let newNFT = new NFT({name, slug, symbol, description, verifiedStatus, bannerUrl, logoUrl, floorPrice, stats, social})
            NFT.replaceOne({"name": name}, newNFT, {returnDocument: "after"})
        }
    })

The reason for this question is, I have run console.log(NFT.find({“name”: name}) and gotten an object back with all of the fields however, they don’t seem to update in my database online. Because it pulls information from the web database, I know I’m connected, but they just aren’t updating. What am I doing wrong here?