• February 22, 2023
    <?php
    $y = 1234;
    $x = 100000;
    $xx = number_format($x);
    $yy = ($y * 10);
    $yy1 = ($y * 30);
    
    $initial_yy_value = 1000;
    $initial_yy1_value = 1000;
    
    $initial_value = 1000;
    $xx_increase_per_year = $xx;
    
    $yy_increase_per_year = $yy;
    $yy1_increase_per_year = $yy1;
    
    // Set up data arrays
    $data = [];
    
    // Generate data for chart
    $current_age = $age;
    $max_age = min($age + 20, 100);
    while ($current_age <= $max_age) {
        $data[] = [
            'x' => $current_age,
            'y' => $initial_value,
            'z' => $initial_yy_value,
            'r' => $initial_yy1_value,
        ];
    
        $initial_value += $xx_increase_per_year;
        $initial_yy1_value += $yy1_increase_per_year;
        $current_age++;
    }
    ?>
    
    <!-- Include chart.js library -->
    <script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
    
    <!-- Create a canvas element to render the chart -->
    <canvas id="myChart"></canvas>
    
    <script>
    // Get the canvas element
    var ctx = document.getElementById('myChart').getContext('2d');
    
    // Create the chart
    var chart = new Chart(ctx, {
        type: 'scatter', // Use scatter chart type for 3D plot
        data: {
            datasets: [{
                label: 'My Dataset',
                data: <?php echo json_encode($data); ?>,
                backgroundColor: 'rgba(255, 99, 132, 0.2)',
                borderColor: 'rgba(255, 99, 132, 1)',
            }]
        },
        options: {
            scales: {
                x: {
                    type: 'linear',
                    position: 'bottom',
                    title: {
                        display: true,
                        text: 'Age'
                    }
                },
                y: {
                    type: 'linear',
                    position: 'left',
                    title: {
                        display: true,
                        text: 'XX Data'
                    }
                },
                z: {
                    type: 'linear',
                    position: 'right',
                    title: {
                        display: true,
                        text: 'YY Data'
                    }
                }
            }
        }
    });
    </script>
    

    3D

    <!DOCTYPE html>
    <html>
    <head>
    	<title>3D Scatter Plot</title>
    	<script src="https://cdn.plot.ly/plotly-latest.min.js"></script>
    </head>
    <body>
    	<div id="plot"></div>
    	<script>
    		// Define data points
    		var x = [1, 2, 3, 4, 5];
    		var y = [5, 4, 3, 2, 1];
    		var z = [3, 4, 1, 5, 2];
    
    		// Define the data object
    		var data = [{
    			type: 'scatter3d',
    			mode: 'markers',
    			x: x,
    			y: y,
    			z: z,
    			marker: {
    				color: 'rgb(0, 255, 255)',
    				size: 10
    			}
    		}];
    
    		// Define the layout object
    		var layout = {
    			scene: {
    				xaxis: {title: 'X Axis'},
    				yaxis: {title: 'Y Axis'},
    				zaxis: {title: 'Z Axis'}
    			},
    			margin: {
    				l: 0,
    				r: 0,
    				b: 0,
    				t: 0
    			}
    		};
    
    		// Create the plot
    		Plotly.newPlot('plot', data, layout);
    	</script>
    </body>
    </html>
    


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

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






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

Categories


Uncategorized