javascript - 通过 postgres 使用 d3.js
问题描述
我目前正在学习 java spring 和 d3.js。并且发现自己遇到了障碍,因为经过无数次反复试验和研究,我似乎无法找到问题的正确答案。
下面的代码是我的控制器:
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;
import dashboard.atmandcam.model.MyModel;
import dashboard.atmandcam.repo.MyRepo;
@RestController
public class MyController {
@Autowired
private MyRepo myRepo;
@GetMapping("/test")
public String sayHi() {
return "hi";
}
@GetMapping("/queries")
public List<MyModel> getResult(){
return myRepo.getQueryResult();
}
@GetMapping("/queries/{id}")
public List<MyModel> getSpecific(@PathVariable String id){
return myRepo.getSpecificResult(id);
}
}
然后这是我的 d3.js
var url = "/queries/31370100";
d3.json(url, function(data) {
console.log(data);
});
我的控制器的结果是带有 URL(http://localhost:9090/queries/31370100):
我想知道如何在 d3.js 中使用我的 url 上的 JSON,以便我可以围绕我的数据库构建图表。
解决方案
推荐阅读
- servicenow - 将 servicenow 与 onedrive 集成。同时尝试获取 onedrive 的 OAuth 令牌获取无效范围错误
- apache-spark - 在 Spark 中分支?
- javascript - 为 JS 动画文本添加延迟
- node.js - npm v6.4.1 未在 docker 内运行`prepare`
- visual-studio-2017 - 防止表单重新缩放自身 - DPI 意识
- angular - 子组件的角度导航
- python - Python中以Text&Key为参数的加密和解密
- r - 在 R 闪亮中单击操作按钮后从数据库更新复选框
- javascript - 给定一个 templateURL 和一个 URL,我如何获取 javascript 中的字段?
- algorithm - 如何有效地在二进制数据框中找到模式?