Amcharts 3 set ValueAxis minimum to negative, make the title to wrong position and valueaxis is missing

When I set ValueAxis to negative, the chart will missing some field(Second image), below are my js code, can anyone help on this?
(And I use Amcharts 3.4.5)

<script>

    Amcharts.ready(function(){
        var chartData=<%# Eval("MyAmchartData")%>;
        //chart
        var chart=new Amcharts.AmSerialChart();
        chart.dataProvider=chartData;
        chart.categoryField="country";
        chart.pathToImages="../amcharts/images/";
        chart.type="serial";
        chart.theme="none";
        chart.addTitle("Customed Chart Title", 15);
        //graph
        var graph=new Amcharts.AmGraph();
        graph.title='-------This is my customed title-------';
        graph.valueField='Name of the value field in my dataProvider';
        graph.type='line';
        graph.bullet='round';
        graph.lineColor='#4572A7';
        graph.labelText='[[tool]]';
        graph.bulletField='bullet';
        graph.colorField='bullet_fillColor';
        chart.addGraph(graph);

        //ValueAxis
        var valueAxis=new Amcharts.ValueAxis();
        valueAxis.position='left';
        valueAxis.title='-------This is my customed title-------';
        valueAxis.titleColor='#4572A7';
        valueAxis.titleFontSize=14;
        valueAxis.axisThickness=1;
        valueAxis.includeGuidesInMinMax=true;
        valueAxis.axisThickness=1;
        valueAxis.axisThickness=1;
        if(<%# Eval("YAxisMax")%>  >100){
            valueAxis.logarithmic=true;
            valueAxis.useScientificNotation=true;
        }
        valueAxis.maximum=10000;
        valueAxis.minumum=-1;
        valueAxis.axisColor='#4572A7';
        valueAxis.axisThickness=2;
        valueAxis.gridAlpha=0;
        valueAxis.axisAlpha=1;
        chart.addValueAxis(valueAxis);
        graph.valueAxis=valueAxis;
        //categoryAxis
        var categoryAxis=chart.categoryAxis;
        categoryAxis.autoGridCount=false;
        categoryAxis.gridCount=chartData.length;
        categoryAxis.gridPosition="start";
        categoryAxis.labelRotation=-90;
        //Legend
        var legend=new Amcharts.AmLegend();
        legend.useGraphSettings=true;
        legend.borderAlpha=1;
        legend.horizontalGap=0;
        legend.position="bottom";
        legend.valueText='';
        chart.addLegend(legend);
        //Cursor
        var cursor=new Amcharts.ChartCursor();
        cursor.cursorPosition='mouse';
        cursor.categoryBalloonAlpha=0.5;
        cursor.graphBulletSize=1;
        cursor.cursorAlpha=0;
        cursor.valueBalloonEnabled=false;
        chart.addChartCursor(cursor);
        //Write
        chart.write("chartdiv");
    });
</script>
<div id="chartdiv" style="width:100%; height:580px;"></div>

Positive minumum to 1:
Positive minumum to 1

Negative minumum to -1:
Negative minumum to -1

I hope the chart can show ValueAxis minimum to -1 and second iamge can work as correct as first image.

Select the Python code snippet that corresponds to the following Javascript snippet

Select the Python code snippet that corresponds to the following Javascript snippet.

`

for (let i = 0; i < 10; i++) {
        console.log(i);
    }

`
This is the question

I’m giving answers below

`

for a in 1..5 do
      
 puts i 

end

`
This is the first answer

and the second answer

`

for (int i = 0; i < 10; i++)
{
print()
}

`
and the third answer

`

for (i in x) 
{
print(i)
}

`
and the fourth answer

`

for (i in x) 
{
print(i)
}

`

Please Pick one of those answers which one is correct.

Date on posts is updated after another post is added ja JavaScript

Currently I am doing a small school project, its a forum where you can add posts, see the date when it was added, sort by date, etc.

My problem here is when the post is added, it always update the latest date on every post (see on screenshot, time between adding them is few minutes)
enter image description here

const date = new Date();

let hour = date.getHours();
let minute = date.getMinutes();
let second = date.getSeconds();
let day = date.getDate();
let month = date.getMonth() + 1;
let year = date.getFullYear();


postsView.innerHTML += `<div class="card mb-3">
    <div class="card-body">
      <p> ${title} [${day}-${month}-${year}, ${hour}:${minute}:${second} AM]: ${description}
      <a href="#" onclick="deletePost('${title}')" class="btn btn-danger ml-5">Delete</a>
      </p>
    </div>
  </div>`;

I tried with:

const date = new Date();
console.log(date.toLocaleString());

but the result is the same.

Thanks! 🙂

Update Old Angular codebase to latest (v15)

I am looking for the least painful way to update an angular application from v7 to v15.
I have started out on it, its a pretty large codebase with loads of packages and implementations that are deprecated. Is there an easier way to go about this?
Thank you for your answers!

I used

ng update @angular/cli

also did for the core angular modules. Its just really a lot and I wanted to find out if there was an easier way around it.

Add same (dev)Dependency, but different use in dev & production

I Have two projects:

  1. common_components repo.
  2. main_project that use these components.

these two project maintaned and developed parallel.
I use the common_components as a devDependency in the main_project.

Tho, the common_components has two version types, a dev version, that after each push to the dev branch an artifactory is created, and another version that once a week I create a main version artifactory.
for example the dev version is d.1.0.0 and the main version m.1.0.0.

in main_project package.json:

   ....
  devDependencies:{
  "common_components": '@same-path-for-dev-and-main-version'
  }

My problem is that when i run build on main_project I want make a difference between the dev and main version of the common_components.
when i build:dev i want the d.1.0.0 version of common_components and when i run build:prod i want the m.1.0.0 version.

is there a way to store the same devDependency with different versions(depends on the build) that it will not collide when i run builds?

I’ve tried to look for package.json rules but i havent find a solution.

Is placing angular animation state in data object a good practice?

I am new to angular and want to learn the angular animation. I was trying to learn animating a list item in a list, but after some reading have come to know that you will have to store the animation state in the data object itself. for example I have a list of subjects and when user clicks on a subject it shows the its contents and highlights parent subject item, but here there is no other way to do it other than storing the state in subject object in angular.
My question is that, is it not confusing the actual data of subject? should not we have to keep the html element state info separate?
please guide me I am confused.

How to automatically increase/decrease order if create a new order request in node.js

I want to make one of my data ‘order’ automatically increase or decrease depends on new request order.

The data like this

id order
1 1
2 2
3 3

The request is to insert a new id and its order is 2, then the origin id 2 and 3’s order need to decrease 1 like this:

id order
1 1
2 3
3 4
4 2

or the request is update id 3’s order to 1 then other’s order need to change automatically like:

id order
1 2
2 4
3 1
4 3

I have no idea how to achieve this result in node.js.
Please help or some suggestion will be very appreciate.

webgl how to draw a ring

As shown below, all I can think of is to describe all the points on a circle and then use triangulation to draw a ring with width

enter image description here

I can also think of a way to use overlay. First draw a circle and then draw a circle with a smaller radius

const TAU_SEGMENTS = 360;
const TAU = Math.PI * 2;
export function arc(x0: number, y0: number, radius: number, startAng = 0, endAng = Math.PI * 2) {
  const ang = Math.min(TAU, endAng - startAng);
  const ret = ang === TAU ? [] : [x0, y0];
  const segments = Math.round(TAU_SEGMENTS * ang / TAU);
  for(let i = 0; i <= segments; i++) {
    const x = x0 + radius * Math.cos(startAng + ang * i / segments);
    const y = y0 + radius * Math.sin(startAng + ang * i / segments);
    ret.push(x, y);
  }
  return ret;
}

const gl = container.current.getContext("webgl2");

const program = initProgram(gl);

const position = new Float32Array(arc(0, 0, 1).concat(...arc(0, 0, 0.9)));

let buffer = gl.createBuffer();
gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
gl.bufferData(gl.ARRAY_BUFFER, position, gl.STATIC_DRAW);

let gl_position = gl.getAttribLocation(program, "position");
gl.vertexAttribPointer(gl_position, 2, gl.FLOAT, false, 0, 0);
gl.enableVertexAttribArray(gl_position);

gl.drawArrays(gl.LINE_STRIP, 0, position.length / 2);

The final effect of the code I wrote is as follows. May I ask how I should modify it to become the same as the above picture

enter image description here

Why is my nested loop only finding one duplicate character in a string?

My apologies if this is a duplicate, I couldn’t find an answer after searching for a while on Stackoverflow.
I am trying to use a nested loop to find any duplicate characters in a string.
So far, all I can manage to do is to find one duplicate the string.

For example, when I try the string “aabbcde”, the function returns [‘a’, ‘a’], whereas I was expecting [‘a’, ‘a’, ‘b’, ‘b’].

I obviously have an error in my code, can anybody help point me towards what it could be?

const myStr = "aabbcde";

function duplicateCount(text){
  const duplicates = [];
  for (let i = 0; i < text.length; i++) {
    for (let j = 0; j < text[i].length; j++) {
      if (text[i] === text[j]) {
        duplicates.push(text[i]);
      }
    }
  }
  return duplicates;
}

duplicateCount(myStr);

Why extending property of existing object with arrow function fails [duplicate]

Why arrow function fails to identify this pointer in the following case. I know that regular functions have their own execution scope and this but I could not identify why following failed. In the arrow function case, this is undefined. If someone can shed light, it would be great. Thank you!

PS: This code is just for experimental purposes, not anything serious.

const addProperty = function(op, func) {
  String.prototype.__defineGetter__(op, func);
};

// works
addProperty('upper', function() {
  return this.toUpperCase();
});

// fails to identify this
addProperty('lower', () => {
  return this.toLowerCase();
});

How to update state shared between Parent and Child React components within the Parent

I’ve built a simple interface for selecting items from a menu, contained in a component called Sodas, and it’s displayed in the Parent component: VendingMachine.

As it is, Sodas is able to successfully change the state in the VendingMachine, however, the state cannot be changed within the VendingMachine itself.

The following code represents the VendingMachine component:

import Sodas from './Sodas';

const VendingMachine = () =>
{
   // Track selected soda
   const [selectedSoda, setSoda] = useState({ sodaName: '', stock: 0 });

   const handleSodaSelection = (soda) => setSoda(soda);

   // Reset the selected soda
   const sellSoda = () => setSoda({ sodaName: '', stock: 0 });

   return (
   <div>
      Soda to Purchase: {selectedSoda.sodaName}
      <Sodas handleSodaSelection={handleSodaSelection} />
      <div onClick={sellSoda}>Buy Selected Soda</div>
   </div
}

The following code represents the Sodas Component

function Sodas({ handleSodaSelection  })
{
   // Tracks soda selected, and returns to Parent component
    const [sodaSelected, setSodaSelected] = useState({ sodaName: '', stock: 0 });
    React.useEffect(() => handleSodaSelection(sodaSelected), [sodaSelected, handleSodaSelection]);

return (
   <div className='soda_container'>
      <div onClick={() => setSodaSelected({ sodaName: 'Cola', stock: 7 })}>Soda</div>
   </div>)
}

Specifically, the issue is that setSoda does not work within VendingMachine and only works when passed to the Sodas component. I’m not sure if this can only work as a one way relationship or if there is something I’m missing in the syntax.

Any help or references to relevant documentation would be greatly appreciated.

Image is not moving away from cursor

i have a image ,i want whenever cursor try to touch the image it moves away randomly from the cursor i tried using jquery but it not working , see this link http://jsfiddle.net/emreerkan/atNva/

my index.html

 <!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">
    <title>Document</title>
    <link rel="stylesheet" href="style.css">
   


    <script src="https://code.jquery.com/jquery-3.6.1.min.js" integrity="sha256-o88AwQnZB+VDvE9tvIXrMQaPlFFSUTR+nldQm1LuPXQ=" crossorigin="anonymous"></script>
</head>
<body>

    <img src="https://images.pexels.com/photos/569986/pexels-photo-569986.jpeg?auto=compress&cs=tinysrgb&w=600" width="100" height="100" alt="Grey Square" class="som" />
    
    
</body>
<!-- <script src="jquery-3.6.1.min.js"></script> -->
<script>
    alert('hi')
    jQuery(function($) {
    $('.som').mouseover(function() {
        var dWidth = $(document).width() - 100, // 100 = image width
            dHeight = $(document).height() - 100, // 100 = image height
            nextX = Math.floor(Math.random() * dWidth),
            nextY = Math.floor(Math.random() * dHeight);
        $(this).animate({ left: nextX + 'px', top: nextY + 'px' });
    });
});
</script>
</html>

my style.css

body { position: relative; }
#img { position: relative; }

Cypress Error: connect ETIMEDOUT cy.visit()

I am receiving an abnormal visit error in cypress browser. However if I visit the same url in normal browser, it works. Here is the screenshot of the error.

enter image description here

I’ve tried this:

      cy.visit(this.hrefLink, {
        timeout: 30000, 
        headers: { 
          "Accept-Encoding": "gzip, deflate, br",
          "Accept-Language": "en-US,en;q=0.5",
          "Content-Type": "text/html"
        } 
      });