score:0
You can change the opacity property on the event depending on the filter as such:
d3.selectAll(".events").attr('opacity', d => {
const includes = genreType.filter(item => d.Genre.indexOf(item) !== -1)
return includes ? 1 : 0
})
this will work on the assumptions that d.Genre is a string as such "Standup, Comedy Rock, Comedy, Standup Comedy, Funny, Humor"
and genreType is an array of keywords as such: ["Standup", "Comedy"]
.
Of the genreType is another string you should execute a split as such .split(/, ?/g)
in order to convert it
Source: stackoverflow.com
Related Query
- Filtering by an array in D3 (filtering by array of string keywords)
- Javascript Concatenate Array to String
- D3 create buttons from an array of string containing names
- Turn string to array name in D3 Javascript
- d3 v5 scaleThreshold not accepting array of string colors on range?
- filtering a data array so that it only return even index columns in d3
- Filtering array in d3
- Adding string field to the data array so as to obtain the string on mouse-hover.
- Filtering GeoJSON data using array of values to create Leaflet map
- d3.js tree with json string dont recognize as Array
- set style conditionally with if value of variable matches specific string in array
- D3js take data from an array instead of a file
- Loading D3.js data from a simple JSON string
- csv to array in d3.js
- Is there a way to tell crossfilter to treat elements of array as separate records instead of treating whole array as single key?
- How to find the max/min of a nested array in javascript?
- D3.js: Get an array of the data attached to a selection?
- Convert SVG Path d attribute to a array of points
- Using an associative array as data for D3
- How to get maximum value from an array of objects to use in d3.scale.linear().domain()
- converting numbers on y axis to string with K for thousand d3.js
- nvd3 line chart with string values on x-axis
- Render D3 graph from a string of JSON instead of a JSON file
- D3.js - JSON data array is binding the same array element to everything
- D3 JS Data Filtering
- Returning array from d3.json()
- D3: Using node attribute for links instead of index in array
- Filling the gaps in D3 array nesting
- Why does d3.select() return array of array?
- Retrieving Keys from JSON Array key-value pair dynamically - Javascript
More Query from same tag
- Tweening text in d3.js - count up
- Line Plus Bar Chart - Is there any way to pass date as string without formatting?
- CSS transform-origin not working for svg in safari
- is there a way to add drag and drop in svg d3.js?
- D3 linechart string domain x-axis
- D3 Data Loading For A Choropleth Graph or Heat Map
- Links are directed to top left corner in forceNetwork with networkD3 in R
- Why does this vanilla js function return different results in d3v3 and d3v4
- Cubism d3 dependency with requirejs
- Create nested output
- Display text and direct via hyperlink on d3 Map
- Create custom a d3 generator
- SVG `<path>` Imprecision
- How do you allow d3js plot to run off screen
- show data of each circle of bubble chart in table d3.js
- D3 Geo albers USA map showing Puerto Rico and Virginia incorrectly
- Different Tooltip for each SVG circle on D3 Map
- d3js - adding a speech-bubble like tooltip?
- Javascript not waiting for return value
- D3 Only Loading One Cell of Data
- in d3js bar chart i want to have fixed bar width
- d3 text function on a selection giving undefined
- Bar-chart toggling between 3 variables in an array
- why d3 line chart and bar chart display in same morment?
- D3js: When to use .datum() and .data()?
- scroll while dragging element with d3.js
- dc.js Using two reducers without a simple dimension and second grouping stage
- Integrating D3-Chart into existing HTML site
- Loading csv data and save results to a variable
- D3 - Using a variable as file path