d3 / d3-selection

Transform the DOM by selecting elements and joining to data.

Home Page:https://d3js.org/d3-selection

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

D3 Logic (greater than equal) Issue

hweehwang opened this issue · comments

Hi, I am trying to filter a data using D3.

My data (data_Date) list looks like
image

The code I wrote is
var data_Date_Threshold = data_Date.filter(function(d) {return d.Precipitation > x});

When I use x = 2 it only filters Precipitation = 4 and 5 without including 10 and 12.

When I use x = 1, it works fine. I guess it only looks the first number instead of whole number (e.g., 10 = 1, 12 = 1, or 20 = 2).

Can you help me to resolve this issue?

Thanks

Please use Stack Overflow tag d3.js to ask for help. Stack Overflow provides a better collaborative forum: thousands of D3-related questions have been asked there, and some answers may be relevant to you.

When asking for help, please include a link to demonstrate the issue, preferably as an Observable notebook. It is often impossible to debug from code snippets alone. Isolate the issue and reduce your code as much as possible before asking for help. The less code you post, the easier it is for someone to debug, and the more likely you are to get a helpful response.

If you have a question about D3’s behavior and want to discuss it with other users, also consider the d3-js Google Group or joining the d3-js Slack.

Thank you! 🤗