About This Article
This article was created using an automated generation workflow leveraging generative AI. Referring to the official Plotly.js documentation, we produced a static web learning material that includes a fixed version and license.Verification Status: 🧪 Calculation logic has been verified, browser display has not been verified
We verified the pure functions in logic.mjs on GitHub within a V8 isolated environment. Actual accessibility and interaction on GitHub Pages, as well as WordPress rendering, have not been verified this time.
Manipulating 3D Surfaces with Plotly.js: Height Scale Factor and Visualization of 25 Grid Points
Learn how to create a 3D surface from a 5×5 fictitious grid using Plotly.js, change the viewpoint with the mouse, and adjust the height scale factor from 1 to 3.
You can implement interactive JavaScript learning materials even on static sites. However, using a third-party library is different from deploying it to an actual enterprise system. First, observe the changes in results through screen interaction, and understand the mechanics and verification conditions.
Get Started
Plotly.js Live Demo(Public URL accessibility and actual browser operation are unverified)
The maximum height is 16 at a scale factor of 1, and 48 at a scale factor of 3. Both consist of a 5×5 X and Y grid totaling 25 grid points, meaning the number of measurement items does not increase when the scale factor is changed. Please distinguish between visual changes caused by rotating the viewpoint and changes to the raw data.
Change only one condition from the initial input, andbe mindful of whether the source data has changed or only the rendering conditions have changed.Also check if reverting the operation restores the expected result. Especially since graphs and charts exhibit prominent visual changes, verifying the results numerically is also important.
Technologies Used
| Item | Description |
|---|---|
| Library | Plotly.js 3.1.0 |
| Distribution | Static HTML/CSS/JavaScript on GitHub Pages |
| License | MIT (full license text included in vendor) |
| Code Acquisition | Fixed version from official GitHub. No runtime CDN. |
| Data | Fictional values only |
| Verified | V8 inspection of separated logic |
| Unverified | Public URL reachability, actual browser operation, and WordPress display |
How it works and division of roles
It provides a Z-matrix to the Plotly.js surface trace and renders it using WebGL. The function that generates Z can be tested independently, and Plotly.react handles rendering updates. Separating rendering from logic is the key to isolating browser-dependent issues.
Next is the computational logic of the instructional material. Even if it cannot be rendered in a browser, you can separately verify whether the values passed to the screen are as expected. The completed user interface requires all files: HTML, CSS, app.mjs, and vendor. Do not assume that this snippet alone is functional.
export const axis=[0,1,2,3,4];
export function surface(scale){const n=Number(scale);if(!Number.isFinite(n)||n<1||n>3)throw new RangeError("倍率1〜3");return axis.map(y=>axis.map(x=>x*y*n));}
export function maximum(z){return Math.max(...z.flat());}
This separation allows you to diagnose calculation errors and visual glitches separately. Just because the screen does not display does not mean the source data is incorrect. Conversely, even if the screen looks neat, it is useless if the source data or calculation conditions are wrong.
The meaning of changing a single condition
While 3D makes depth easy to understand, it risks exaggerating differences in values depending on the viewpoint and axis scaling. In business comparisons, displaying maximum values and units in text, and appending a 2D table when necessary, helps avoid misunderstandings.
Record the modified inputs and results before proceeding to the next condition. Changing multiple values at once makes it difficult to determine what caused the change. First, learn the behavior using dummy inputs, and verify the boundary values in the official specifications if necessary.
Troubleshooting when it does not work
Check for browsers that do not support WebGL, GPU settings, file loading, and the dimensions of the Z-array. It is important not to report a successful render when the screen is completely blank.
| Symptom | Location to check | Isolation |
|---|---|---|
| URL cannot be opened | Pages deployment and HTTP response | Publishing-side issue |
| Blank screen | vendor, DOM, Console | Loading/execution issue |
| Actions are not reflected | Input events and update processing | State management issue |
| Numbers and screen do not match | Source array and display settings | Calculation and rendering issue |
What was performed in this verification is the isolation check of the calculation part. We have not verified the actual browser operation of the library itself or the production WordPress display. Not treating unperformed operations as verified is important for technical articles that aim to reproduce failures.
When applying to actual work
The maximum height is 16 at a scale factor of 1, and 48 at a scale factor of 3. Both consist of a 5×5 grid in X and Y, totaling 25 grid points, meaning that changing the scale factor does not increase the number of measurement points. Also, distinguish between changes in appearance caused by rotating the viewpoint and modifications to the raw data. On the other hand, before scaling this up for enterprise data, keep in mind that while 3D makes depth easier to grasp, it risks exaggerating value differences depending on the viewpoint and axis scaling. For business comparisons, displaying maximum values and units as text, and supplementing with 2D tables when necessary, helps prevent misunderstandings.
When expanding for operational use, it is necessary to consider access permissions, success or failure of persistence, audit trails for updates, recovery upon failure, and the prevention of data mix-ups. Browser-based static demos are intended for explanation and do not substitute for a production database and authenticated system.
Static Bundling and Security Management
Rather than loading the library core from an external CDN every time,docs/demos/plotly-3d-data-explorer/vendor/a fixed version is bundled locally. Because this is third-party software, the source, version, and license must be clearly specified in the README, and library updates should be performed only after intentional verification. While this makes the setup less susceptible to sudden changes on external CDN providers, it does not mean that security updates are applied automatically.
Use only fictitious data and never include information about real people, companies, or confidential systems in public learning materials. Even with third-party code, the responsibility remains on the user executing it to verify permissions, network connections, and future library updates. Unauthorized scripts or iframes are not inserted into WordPress article bodies, maintaining the conventional delivery route.
Summary
We create a 3D surface from a 5×5 fictitious grid and learn how to change the viewpoint using the mouse and adjust the height scale factor from 1 to 3. By following the sequence of "operating and checking the result," "explaining the reason for the change," and "modifying just one condition to compare," you can transform an interactive library into a technical learning experience. By reviewing the README and source code of the completed version, you can also verify the steps to reproduce it as a static site.
Official Documentation and Code
Live Demo(Actual reachability and actual browser operations unverified)
Verification Scope
Calculation logic was verified in an isolated V8 environment, and the static educational materials, version-pinned third-party library, and license were saved to GitHub. Actual operations on real browsers, screen rendering, appearance in production WordPress, smartphones, and differences between Windows and macOS remain unverified.
