简体   繁体   中英

Displaying charts with D3.js

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.

Partial answer to my own question, and I feel stupid here. Y-axis is upside down? Try swapping the range! It worked. One part down. Editing to comment on the x-axis issue. Could it be a translation issue? I see that the y-axis is drawn, but the x-axis is formatted differently.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM