graphing

by frogggeee McFrogggeee

HTML

<head>
	<!-- Load plotly.js into the DOM -->
	<script src='https://cdn.plot.ly/plotly-2.35.0.min.js'></script>
</head>

<body>
	<div id='myDiv'><!-- Plotly chart will be drawn inside this DIV --></div>
</body>

JavaScript

let data1 = {
  adjusted: true,
  count: 10,
  queryCount: 10,
  request_id: "e557d50f56a3b2f1f5cd54edb7eea2cc",
  results: [{
    c: 129.89,
    h: 130.3,
    l: 129.6,
    n: 85,
    o: 129.6,
    t: 1673254800000,
    v: 2312,
    vw: 129.8763
  }, {
    c: 129.7,
    h: 129.8,
    l: 129.68,
    n: 74,
    o: 129.8,
    t: 1673254860000,
    v: 6206,
    vw: 129.7086
  }, {
    c: 130,
    h: 130,
    l: 129.8,
    n: 83,
    o: 129.84,
    t: 1673254920000,
    v: 2386,
    vw: 129.8947
  }, {
    c: 129.99,
    h: 130.01,
    l: 129.99,
    n: 81,
    o: 130,
    t: 1673254980000,
    v: 3372,
    vw: 130.007
  }, {
    c: 129.99,
    h: 129.99,
    l: 129.98,
    n: 41,
    o: 129.98,
    t: 1673255040000,
    v: 1087,
    vw: 130.0019
  }, {
    c: 130.14,
    h: 130.14,
    l: 130.06,
    n: 58,
    o: 130.08,
    t: 1673255100000,
    v: 3582,
    vw: 130.0971
  }, {
    c: 130.05,
    h: 130.17,
    l: 130.05,
    n: 90,
    o: 130.15,
    t: 1673255160000,
    v: 4540,
    vw: 130.1249
  }, {
    c: 130,
    h: 130.05,
    l: 129.98,
    n: 70,
    o: 130.05,
    t: 1673255220000,
    v: 1712,
    vw: 130.0115
  }, {
    c: 129.99,
    h: 130,
    l: 129.98,
    n: 23,
    o: 129.98,
    t: 1673255280000,
    v: 2542,
    vw: 129.9855
  }, {
    c: 129.95,
    h: 129.97,
    l: 129.9,
    n: 50,
    o: 129.97,
    t: 1673255340000,
    v: 1227,
    vw: 129.937
  }],
  resultsCount: 10,
  status: "OK",
  ticker: "AAPL"
}

var graph = {
	
  x: [],

  close: [],

  decreasing: {
    line: {
      color: 'red'
    }
  },

  high: [],

  increasing: {
    line: {
      color: 'lime'
    }
  },

  line: {
    color: 'rgba(31,119,180,1)'
  },

  low: [],

  open: [],

  type: 'candlestick',
  xaxis: 'x',
  yaxis: 'y'
};
for (let i = 0; i < data1.results.length; i++) {
// year month day
// currently in month day year
let date = new Date(data1.results[i].t).toLocaleDateString().split("/");
let newDate = date[2] + "-"+  date[0] + "-" +...