✊🏿 Black Lives Matter. Please consider donating to Black Girls Code today.
⚾️ It's finally Baseball season! Root for the home team... & Register for our Sports Analytics Webinar!

Graph not showing on change in input

I have taken a sample CSV file where I want to plot the amount of money spent each day by someone where the x-axes will have the days which is equivalent to the rows and Y-axis has the amount which will change with change in the name chosen from the dropdown box, I am able to get the input in Option but am unable to show the graph on the screen, it is showing nothing on the screen except the axis. Can you help me what is the issue here?
(Selected is a function the will push the value chosen by the dropdown into axisValue which is later used to make graph)

The html tag is like this:



function Selected() {
 var axisValue = $("#Btn :selected").val();

 Plotly.d3.csv(expence.csv, function(allRow){

 var data=[];
 var layout= {
 xaxis: {'title': 'Days'}, 
 yaxis: {'title':'Amount'},
 titlefont: {
     family: 'Open Sans,sans-serif ', 
     size: 15, 
     color: '#000'
    } 
 };

 Plotly.plot("myDiv", data, layout);

    function plot(){
      var x_row = [], y_amt = [];

      for (var i=0; i<allRow.length; i++){
         xrow = i;
         row = allRow[i];
         x_row.push(xrow);
         y_amt.push(+row[axisValue]);
              
         var dataRow = {
           x: x_row,
           y: y_amt,
           type: 'lines',
              line: {
               color: '#000',
               width: 2
               }
         };
       }
       Plotly.restyle(myPlot1, 'y', [[]]);
       Plotly.newPlot(myPlot1, data[dataRow]);
      }
});