Apache Echarts, how to customize the tooltip in Scatter 3D?

I am currently working on an Angular14 project that utilizes the Scatter3D plot feature of the Apache Echarts library. However, I am currently experiencing some difficulty in customizing the tooltip information. I kindly request your assistance in resolving this matter. Attached is a screenshot for reference. Thank you for your time and consideration.
Apache Echarts Scatter3D chart

And this is the code snippet for the feature.

const options = {
  grid3D: {},
  tooltip: {},
  xAxis3D: {
    name: 'Total(USD)',
    nameTextStyle: {
      fontSize: 10
    },
    type: 'value',
    axisLabel: {
      formatter: (value: any) => '$' + shortenNumber(value),
      fontSize: 10
    }
  },
  yAxis3D: {
    name: 'Payout',
    nameTextStyle: {
      fontSize: 10
    },
    type: EchartsAxisType.Value,
    axisLabel: {
      formatter: (value: any) => '$' + shortenNumber(value),
      fontSize: 10
    }
  },
  zAxis3D: {
    name: 'Ratio(%)',
    nameTextStyle: {
      fontSize: 10
    },
    type: EchartsAxisType.Value,
    axisLabel: {
      formatter: (value: any) => formatPercent(value / 100, 'en-US', '1.2-2'),
      fontSize: 10
    }
  },
  series: [
    {
      name: 'Analytics',
      type: 'scatter3d',
      symbolSize: 2,
      data: plotdata,
      dimensions: ['Total', 'Payout', 'Ratio']
    }
  ]
};

The shortenNumber is the function to get the abbreviated format from a long number.

How to build an inverted index to search documents using IndexedDB

Suppose you have a collection of ~3000 photos. You have a JSON file that looks something like this:

// photo_data.json

[
  {
    photo_id: 123,
    photo_tags: ["bird", "animal", "nature"],
    uri: ...
  },
  {
    photo_id: 456,
    photo_tags: ["dog", "animal", "cute"],
    uri: ...
  },
]

The objective is to build a Javascript web app with a search bar that allows the user to find images. Ideally, it would match tags exactly and fuzzily.

I am thinking of using an inverted index based on the tags, but I am not sure how to cover the case that the search term does not exactly match the tag. For example, the user may enter “do”, and the expected behaviour would be that web app shows them photo_id 456.

Any thoughts on how to support this using IndexedDB?

nestjs exported const variable reference error

config.ts

`export const ApiConfig = {
  ApiKey: process.env.TEST_API_KEY,
  ApiSecret: (process.env.STAGE === 'PROD') ? 'prod_key' : 'local_key'
}`

service.ts

`import { ApiConfig } from '../config'

@Injectable()
export class TestService {

  constructor() { }

  private readonly API_KEY = ApiConfig.ApiKey;
  private readonly SECRET_KEY = ApiConfig.ApiSecret;

  async func1() {
    const params = {
      property1: this.ApiKey,
      property2: this.ApiSecret,
    }
    ....
    return result;
}`

as above
The const object defined in config.ts is used in service.ts.

property1 has undefined value,
property2 has ‘prod_key’ or ‘local_key’ value

Why?

Strangely, not in the local environment
In the ec2 instance, both properties are entered.

Veeva Tutorial – where can I learn Veeva MyInsights/HTML content creation?

I’m trying to learn making a presentation/slide with javascript & html with Veeva, but I don’t know where to start. I tried to read the api docs but it’s very short and not doesn’t explain most functions. Also, the CLM content creation guide doesn’t provide any detailed instructions on how to start especially on slide navigation which I need the most. It talks about vod ids and such, where they didn’t explain where to get.

What I’m looking for is a tutorial that can guide me from start to finish, that includes explaining where to get the data and the functions available.

React Navigation – How to handle navigating to screens from different navigators?

I have a Tab Navigator with a native stack navigator in each tab. In some cases I want to navigate to a screen, that is in a different tab. This is possible, but there is no animation and the back button goes back only to the screens in the one tab.

I could also just add the screens I need to the tab, but I am using typescript and in every screens props, the navigator is specified. This becomes very impractical if you can navigate to other screens from this one screen – I would have to add all of them to the specified navigator.

Reactjs: set input value doesn’t work when onChange although state is updated

I have an input

<input
  value={state.logInData.email}
  spellCheck={false}
  id='login-email'
  type='email'
  placeholder=' '
  onChange={(e) => {
    console.log(e.target.value)
    dispatch({ type: 'UPDATE_LOGIN_EMAIL', payload: e.target.value })
  }}
/>

I use useReducer to manage state:

initState = {
  menuList: [],
  modalAction: '',
  modalContent: {},
  logInData: {
    email: '',
    password: '',
  },
}

Case for update state of email:

case 'UPDATE_LOGIN_EMAIL':
  return {
    ...state,
    logInData: {
      ...state.logInData,
      email: action.payload,
    },
  }

The problem: when I type in input, state is updated but the state logInData.email have only the char I just type. And the value in input is empty. I guest it is caused by input can’t update value but I don’t have any idea.

How do I modify Jmespath function to Javscript equivalent function

This is my sample data:

{
  "entity": "student",
  "records": [
    {
      "associatedStudentId": 111,
      "data": {
         "info":{
           "position": 1,
           "id": 111
         },
         "entity":{
            "id": 222
         }
      }
    },
    {
      "data": {
         "info":{
           "position": 2,
           "id": 222
         },
         "entity":{
            "id": 222
         }
      }
    }
  ],
  "PersonalInfo": {
      "111":{
        "Father_Name": "Amar"
      },
      "222":{
        "Father_Name": "Akbar"
      }
  }
}

This is my jmespath function

    #input | if(
    entity == 'student',
    
    { 
        student: values(per_info)[*].{key: @[0].info.id, value:@},
        stud_info: records[*].{key: data.entity.id, value: @},
        joined: list_join($.student, $.stud_info, &key, &key)[*].{
            key: left[0].key,
            student: left[0].value,
            info_data: right[0].value
        }
    }.joined,

    //Else
    if (
        entity == 'institution',
        { 
            sales: records[*].{key: associatedStudentId, value:@},
            stud_info: values(StudentInfo)[*].{key: entity.id, value: @},
            joined: map(&
            {
                key: left[0].key,
                student: left[*].value.data,
                info_data: {
                position: add(`1`, __index),
                info_data: right[0].value
                }
            }, 
            list_join($.student, $.stud_info, &key, &key)
            )
        }.joined,
        
        `{}`//Unknown
    )
)

Now how do I convert this function to javscript equivalent ?

how to imbed an app.js page into an index.html page

I have a node application and everything runs from an app.js page. And i am trying to deploy the application but the hosting website is looking for an index.html file from my project to start the website. how can i imbed (or convert) my app.js page into an index.html page?

This is the app.js file.

  require("dotenv").config();
};

const express = require('express');
const mongoose = require('mongoose');
const ejsMate = require('ejs-mate');
const path = require('path');
const Application = require('./models/application');

const indexRoutes = require('./routes/index');

const app = express();

app.engine("ejs", ejsMate);
app.set('view engine', 'ejs');
app.set('views', path.join(__dirname, 'views'));

app.use(express.static(path.join(__dirname, "public")));

app.use('/', indexRoutes);

app.use((req, res) => {
  res.status(404).render("404")
});

const port = process.env.PORT || 3000;

app.listen(port, () => {
  console.log(`Server has started on port ${port}`)
});`


How to add circular dependencies with node zod.js?

I am new to zod and have a circular dependency defined like this

https://www.npmjs.com/package/zod

const eDBAndSchema = z.object({
  and: z.array(z.lazy(() => eDBWhereSchema))
})

const eDBOrSchema = z.object({
  or: z.array(z.lazy(() => eDBWhereSchema))
})

const eDBWhereSchema = z.union([
  eDBAndSchema,
  eDBOrSchema,
  eDBClauseSchema
])

But it complains because they end up having type any

But it works in regular typescript

interface EDB_And {
    and: EDB_Where[];
}

interface EDB_Or {
    or: EDB_Where[];
}

type EDB_Where = EDB_And | EDB_Or | EDB_Clause;

how can I fix this?

NextJs export folder “out” doesn’t have index.html

I build a nextjs app and i wanted to use static export the project and hosted on my hosting.
the app is simple so i didn’t use most of the features that nextjs offers.
when i run:
npm run build (next build && next export)
i get .next folder and out folder which has the following folders:
/static /chunks /css /media

I have all the needed settings (ie: output: “export”, in next.config.js..)

I’m supposed to get all the static htmls files.. any solutions please?


How do I generate an entity and code in an ‘in-game’ time that changes attributes such as the age of an entity?

I want to make a game that logs multiple things.

  • Character (Displayed on html the list of its attributes, generated upon the push of a button, such as a “Generate Person” button. (vvv))
  • Name (Name of a character – auto-generated)
  • Age (From 18-60 – auto-generated)
  • Time (in years, incrementing by 1 every time an “Advance Year” button is pushed.

Therefore, every time the “advance year” button is pushed, the characters who have been generated after pushing its own button will have an age displayed as one plus their original auto-generated age.

I am new to coding and all this is so new to me, but I really am inspired to make a simulator-type auto-generation.

I cannot seem to get the updated-yearly age to display on HTML. I apologize if this is janky and looks stupid, I am very new to coding and this project has stumped me.

[ My Javascript, HTML, written on VSC]

Here is my Javascript code so far:

    const testTime = document.createElement("testTime");
    testTime.classList.add('testTime');
    document.body.appendChild(testTime);
    testTime.setAttribute("id", "testTime");
    var cEBtn = document.createElement("button");
    document.body.appendChild(cEBtn);
    cEBtn.innerHTML = "Change Year";
    cEBtn.setAttribute("id", "cEBtn");
    testTime.innerHTML = "Year: 0";
    let year = 0;
    cEBtn.onclick = function changeYear() {
        year++;
    testTime.innerHTML = "Year:" + " " + year;
        return year;
}
console.log(year);


//Attribute: Name
let firstNames = ["Kai", "Luca", "Talon", "Marce", "Caleb", "Debra",
 "Yvette", "Grey", "Ellison", "Judan", "Indigo", "Zion"];

let lastNames = ["Samuels", "Hillick", "Kori", "Asher", "Paul", "Ozzla",
 "Allen", "Belko", "Wilson", "Adams", "Johnson", "Pierceson"];


//Create Person Function


function createPerson()  {

    const resident = document.createElement("resident");
    resident.classList.add('resident');
    document.body.appendChild(resident);
    const name = document.createElement("div");
    resident.append(name);
    name.setAttribute("id", "name");
    name.innerHTML = determineName();
    
    function determineName() {
    let name = firstNames[Math.floor(Math.random() * firstNames.length)] + " " + lastNames[Math.floor(Math.random() * lastNames.length)];;
        return name;
}
    var age = document.createElement("div");
    resident.append(age);
    age.setAttribute("id", "age");
    let Age = Math.floor(Math.random() * (60 - 18) + 18);
    age.innerHTML = Aging();
    function Aging(){
        return Age;
    }
    if (cEBtn.onclick === true){
        age.innerHTML = Aging()++;
    }
}

if (cEBtn.onclick == true){
    console.log("Hi")
}

Here is my HTML file:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="style.css">
    <title>Document</title>
</head>
<body>
    <header>
        <div class="header-title-container"></div>
        <h1>simulation prototype</h1>
    </div> 
    <button class="createperson" onclick="createPerson()">Create Person</button>
    </header>

    <script src="index.js"></script>
</body>
</html>

[I also apologize if I formatted this question incorrectly.]

golang template string in javascrip function param error

quick question. I am using golang templates and I am trying to pass a golang string to param in a javascript function.

onclick="Pressed('{{.Country.CountryName}}', this)"

I tried a couple of different approaches such as?

onclick="PressedLetter("{{.Country.CountryName}}", this)"
onclick="PressedLetter('"+{{.Country.CountryName}}+"', this)"
onclick="PressedLetter({{.Country.CountryName}}, this)"

all of the above approaches breaks my html and gives me a blank screen.

when I do the following line, it works flawlessly.
onclick="PressedLetter('usa', this)"

my java script method being called:
function PressedLetter(country, x)

Does anyone knows how to do this ? pls ?
thks in advanced

How to make JavaScript code safe and secure so that API Key values cannot be open to public yet available for JavaScipt to process the code [duplicate]

const form = document.querySelector('.subsform');
    const submitButton = form.querySelector('input[type="button"]');
    const messageDiv = document.querySelector('#newsletter-message');

submitButton.addEventListener('click', (event) => {
  event.preventDefault();
  
  const firstName = form.querySelector('input[placeholder="First Name"]').value;
  const lastName = form.querySelector('input[placeholder="Last Name"]').value;
  const email = form.querySelector('input[type="email"]').value;
  const apiKey = form.querySelector('input[name="mailchimpAPIkey"]').getAttribute('data-api');
  const listId = form.querySelector('input[name="mailChimpListId"]').getAttribute('data-listId');
  
  console.log({ firstName, lastName, email, apiKey, listId });
  
  const url = `https://us20.api.mailchimp.com/3.0/lists/${listId}/members/`;
  const data = {
    email_address: email,
    status: 'subscribed',
    merge_fields: {
      FNAME: firstName,
      LNAME: lastName
    }
  };
  const options = {
    method: 'POST',
    headers: {
      'Authorization': `Basic ${btoa(`apikey:${apiKey}`)}`,
      'Content-Type': 'application/json'
    },
    body: JSON.stringify(data)
  };
  
  fetch(url, options)
    .then(response => response.json())
    .then(data => {
      messageDiv.innerHTML = `Thank you for subscribing, ${firstName}!`;
      console.log(data);
    })
    .catch(error => {
      messageDiv.innerHTML = 'There was an error subscribing. Please try again later.';
      console.error(error);
    });
});

The above Javascript code processes the submit button interaction so that users can be subscribed, but it is vulnerable to security.

I do not know if there is a way to make the code safer as anyone with basic JS knowledge can grab all the hidden input tags with this code pasted in the console:

// Select all hidden input tags on the page
const hiddenInputs = document.querySelectorAll('input[type="hidden"]');

// Loop through all hidden input tags and log them to the console
hiddenInputs.forEach(input => {
  console.log(input);
});