Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
864 views
in Technique[技术] by (71.8m points)

d3.js - D3 How to pass text value from data to variable

I got a great answer yesterday helping me set up a conditional rule that allows me to display the points on my scatter chart as images or dots based on a variable 'displaytype'

Here's the link to the answer: D3 conditionally append image OR circle element based on variable

I'm porting my solution into Power BI and the dataset will contain a field 'display_type' which will be either 'image' or 'dot'

So I'm trying to update my variable and link it to the data but the if statement doesn't seem to recognise the output from the function.

eg

The Current variable is:

var displaytype = "image" // or "dot"

I'm trying to change that to:

var displaytype = function(d) {
  return d.display_type
};

or

var displaytype = function(d) {
  return data[0].display_type
};

However, the result has no impact to the display whatsoever so I guess I'm missing something (probably simple) ?

Any help much appreciated as always

question from:https://stackoverflow.com/questions/65857600/d3-how-to-pass-text-value-from-data-to-variable

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...