首页 \ 问答 \ 使用D3.js显示图表(Displaying charts with D3.js)

使用D3.js显示图表(Displaying charts with D3.js)

我是Javascript和D3JS的新手,所以我会在这里问一下。 在开始之前, 是支持我的特定数据集的原始示例的代码, 是我对它的修改。

我在后端做的是使用PHP(带有一些var base)来设置JS变量名,以在同一页面上显示多个图。 这就是我的修改中每次迭代中“流”的来源。

似乎有些问题可能与我对D3.js如何具体运作缺乏了解有关,并且可能与JS有关。 我可以确认正在正确解析CSV文件,因为它显示的y范围是有效的。

例如,代码显示的图形 具有反转的y轴(具有正确的值),并且不 显示x轴或标签。 此外,实际上没有绘制数据。 我怀疑它可能与错误命名的属性有关,但我不确定。 你有什么想法吗?

编辑:自己修复了y轴问题。 我现在觉得很暗淡。


I'm new to Javascript and D3JS, so I'll try asking here. Before I begin, Here is the code for the original example to support my specific data set, and here is my modification of it.

What I'm doing on the back end is using PHP (with the some var base) to set JS variable names to display multiple graphs on the same page. That's where "stream" comes from in every iteration in my modifications.

There appear to be issues that are likely related to my lack of understanding of how D3.js works specifically, and possibly related to JS in general. I can confirm that the CSV file is being parsed correctly, as the y-range it displays is valid.

For example, the graph displayed by the code has an inverted y-axis (with the correct values) and shows no x-axis or label. Furthermore, no data is actually plotted. I suspect it's likely related to the attributes being incorrectly named placed, but I am unsure. Do you have any thoughts?

Edit: Fixed the y-axis issue myself. I feel quite dim right now.


原文:https://stackoverflow.com/questions/13647697
更新时间:2023-07-29 15:07

最满意答案

你正在调用getClass() 。 这总是返回对象的引用,该对象与对象的实际执行时间类型相关联,而不是您调用它的表达式的编译时类型的类。 例如:

Object foo = "this is a string";
Class<?> clazz = foo.getClass();

clazz将引用String的类,而不是Object的类。

您不需要查看getClass()实现 - 只需查看文档

表示此对象的运行时类的Class对象。

请注意“运行时间”位,如“在执行时确定,而不是在编译时”。

在这种情况下,我认为在toString()的结果中返回执行时类名是完全合理的,但如果你真的真的想要Entity类,你可以只使用Entity.class


You're calling getClass(). That always returns a reference to the Class object associated with the actual execution-time type of the object, not the class for the compile-time type of the expression you call it on. So for example:

Object foo = "this is a string";
Class<?> clazz = foo.getClass();

clazz will refer to the class for String, not the class for Object.

You don't need to look at the implementation of getClass() - just look at the documentation:

The Class object that represents the runtime class of this object.

Note the "runtime" bit, as in "determined at execution time, not at compile time".

In this case I think it's entirely reasonable to return the execution-time class name within the result of toString(), but if you ever really really wanted the Entity class, you could just use Entity.class instead.

相关问答

更多

相关文章

更多

最新问答

更多
  • h2元素推动其他h2和div。(h2 element pushing other h2 and div down. two divs, two headers, and they're wrapped within a parent div)
  • 创建一个功能(Create a function)
  • 我投了份简历,是电脑编程方面的学徒,面试时说要培训三个月,前面
  • PDO语句不显示获取的结果(PDOstatement not displaying fetched results)
  • Qt冻结循环的原因?(Qt freezing cause of the loop?)
  • TableView重复youtube-api结果(TableView Repeating youtube-api result)
  • 如何使用自由职业者帐户登录我的php网站?(How can I login into my php website using freelancer account? [closed])
  • SQL Server 2014版本支持的最大数据库数(Maximum number of databases supported by SQL Server 2014 editions)
  • 我如何获得DynamicJasper 3.1.2(或更高版本)的Maven仓库?(How do I get the maven repository for DynamicJasper 3.1.2 (or higher)?)
  • 以编程方式创建UITableView(Creating a UITableView Programmatically)
  • 如何打破按钮上的生命周期循环(How to break do-while loop on button)
  • C#使用EF访问MVC上的部分类的自定义属性(C# access custom attributes of a partial class on MVC with EF)
  • 如何获得facebook app的publish_stream权限?(How to get publish_stream permissions for facebook app?)
  • 如何防止调用冗余函数的postgres视图(how to prevent postgres views calling redundant functions)
  • Sql Server在欧洲获取当前日期时间(Sql Server get current date time in Europe)
  • 设置kotlin扩展名(Setting a kotlin extension)
  • 如何并排放置两个元件?(How to position two elements side by side?)
  • 如何在vim中启用python3?(How to enable python3 in vim?)
  • 在MySQL和/或多列中使用多个表用于Rails应用程序(Using multiple tables in MySQL and/or multiple columns for a Rails application)
  • 如何隐藏谷歌地图上的登录按钮?(How to hide the Sign in button from Google maps?)
  • Mysql左连接旋转90°表(Mysql Left join rotate 90° table)
  • dedecms如何安装?
  • 在哪儿学计算机最好?
  • 学php哪个的书 最好,本人菜鸟
  • 触摸时不要突出显示表格视图行(Do not highlight table view row when touched)
  • 如何覆盖错误堆栈getter(How to override Error stack getter)
  • 带有ImageMagick和许多图像的GIF动画(GIF animation with ImageMagick and many images)
  • USSD INTERFACE - > java web应用程序通信(USSD INTERFACE -> java web app communication)
  • 电脑高中毕业学习去哪里培训
  • 正则表达式验证SMTP响应(Regex to validate SMTP Responses)