简体   繁体   English

如何使用来自后端的数据和 node.js 在前端绘制图表?

[英]How to plot a chart in the frontend using data from the backend with node.js?

My current situation is this:我现在的情况是这样的:

I have a SQL database that I get my data from on the server side, and I want to show that data in a chart for the user, using Plotly .我有一个 SQL 数据库,我从服务器端获取数据,我想使用Plotly在用户的图表中显示该数据。 But I'm not sure how to approach this: should I pass the data to the frontend and make a chart there, or make the chart on the server side and try to change the content of the HTML ?但我不确定如何处理:我应该将数据传递到前端并在那里制作图表,还是在服务器端制作图表并尝试更改HTML的内容?

Also, in the front end, I would like to use a external script, meaning I can't include plotly as a module, but maybe there is a way to do it?另外,在前端,我想使用外部脚本,这意味着我不能将plotly作为模块包含在内,但也许有办法做到这一点? And if I try to do it on the server side, how should I approach this passing the chart to the front end?如果我尝试在服务器端执行此操作,我应该如何将图表传递到前端?

I'm fairly new to web development thing, trying to grasp the right concept of how data should be passed arround.我对 Web 开发还很陌生,试图掌握如何传递数据的正确概念。

First you need to create an api, this api will serve x and y coordinates in array format.首先你需要创建一个 api,这个 api 将以数组格式提供 x 和 y 坐标。 Please refer following linkhttps://plot.ly/javascript/getting-started/#hello-world-example (in this web-page click on js tab and see the "x" and "y" coordinates.)请参考以下链接https://plot.ly/javascript/getting-started/#hello-world-example (在此网页中单击 js 选项卡并查看“x”和“y”坐标。)

Next make ajax call to above api and subscribe the response.接下来对上面的api进行ajax调用并订阅响应。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何将数据从前端jQuery传递到后端node.js - How to pass data from frontend jQuery to backend node.js 如何在 javascript 前端使用 async await 从 async await node.js 后端接收数据 - how to use async await on javascript frontend to receive data from async await node.js backend 如何从后端获取角度数据并通过node.js发送给前端? - How get data with angular from the backend and send it with node.js for the frontend? 使用纯 js 将数据从 node.js 发送到前端 - Send data from node.js to frontend using pure js 如何从后端节点 js 获取 Json 数据到前端 html - How to get Json data from backend node js to frontend html 来自前端的数据在后端重复两次 React.js Node.js - Data coming from frontend duplicates in backend twice React.js Node.js 如何在 node.js 后端使用 usestate 并响应前端 - how to use usestate with node.js backend and react frontend 如何使用 javascript(Reactjs) 作为前端和 node.js 作为后端创建依赖下拉列表 - How to create dependent dropdown list using javascript(Reactjs) as frontend and node.js as backend 如何在不使用框架的情况下通过Node.js将数据从MongoDB显示到前端 - How to display data from MongoDB to the frontend via Node.js without using a framework 如何从前端react.js中的node.js从多个数据库中获取数据 - How to fetch data from multiple db from the node.js in frontend react.js
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM