• February 21, 2023
    <?php
    if ($_SERVER['REQUEST_METHOD'] === 'POST') {
      // Retrieve the submitted value
      $value = $_POST['value'];
    
      // Process the value (for this example, we'll just double it)
      $processed_value = $value * 2;
    
      // Generate the graph data
      $x_data = array(0, 1, 2);
      $y_data = array($processed_value, $processed_value+1, $processed_value+2);
    
      // Encode the data as JSON for use in the JavaScript below
      $graph_data = json_encode(array('x' => $x_data, 'y' => $y_data));
    }
    ?>
    
    <!-- HTML form -->
    <form method="post">
      <label for="value">Enter a value:</label>
      <input type="text" name="value" id="value">
      <button type="submit">Submit</button>
    </form>
    
    <!-- JavaScript to generate the graph -->
    <?php if (isset($graph_data)): ?>
      <div id="graph"></div>
      <script src="https://cdn.plot.ly/plotly-latest.min.js"></script>
      <script>
        var graph_data = <?php echo $graph_data ?>;
        var trace = {
          x: graph_data.x,
          y: graph_data.y,
          mode: 'lines+markers',
          type: 'scatter'
        };
        var data = [trace];
        var layout = {
          title: 'Graph of <?php echo $processed_value ?>',
          xaxis: {
            title: 'X-axis'
          },
          yaxis: {
            title: 'Y-axis'
          }
        };
        Plotly.newPlot('graph', data, layout);
      </script>
    <?php endif; ?>
    


เวอไนน์ไอคอร์ส

ประหยัดเวลากว่า 100 เท่า!






เวอไนน์เว็บไซต์⚡️
สร้างเว็บไซต์ ดูแลเว็บไซต์

Categories


Uncategorized