score:1
Accepted answer
You only want to use .tickValues
if some condition is met?
var xAxis = d3.axisBottom(x)
.tickFormat(function (d, i) {
if (interval_size === "15" || interval_size === "30") {
return testStringArray[i];
} else {
return dateArray[i];
}
});
if (someCondition){
xAxis.tickValues(x.domain().filter(function (d, i) { return !(i % 2); }));
}
Source: stackoverflow.com
Related Query
- d3 tickvalues in an if statement
- Why are .domain, tickFormat and tickValues not recognised inside dimensions variable? (d3, parallel coordinates)
- d3js set tickValues for time scale axis
- Iterating through an array inside a conditional && statement in javaScript?
- How specify tickValues in d3.js time scale?
- Assign Typescript type in switch statement
- Optimizing javascript d3 statement
- Enter() statement with a function from one data array to multiple arrays? (Adding multiple Gradient Paths)
- D3 visibility - if statement
- D3 Chart - Using tickValues for Time Gives "translate(NaN,0)"
- How to interpret the D3 statement "var r = d3.scale.linear().domain([0,1]).range([5,1000])"?
- d3 path.line stroke-width with IF statement / ternary operator
- Using an if statement in conjunction with creating a mapped variable (Javascript)
- How to get automatically generated tickValues for d3 axis
- d3 - how to show duration interval instead of tickValues
- d3 4.0 - import statement gives __moduleExports wrapper
- Dynamic tickValues on time.scale in D3
- What does the + in this statement do: a = +array[i]
- Only one item get's displayed in x axis d3 - ordinal using tickvalues
- D3 - unable to access d.length in IF statement
- D3 ordinal scale, left and right margins for tickvalues
- how to use css to style if-else statement in d3
- d3 - axis ticks not working unlike tickValues
- for...in statement - what does arbitrary order mean
- 'if' statement not working in D3.js
- tickValues in d3 not working as expected
- Assigning value to variable using if statement
- If statement for D3
- If else statement that disables a button
- Adding style to SVG shape with a conditional statement
More Query from same tag
- Error while running D3.JS v4 on Angular2
- javascript populate nested object from other nested object
- Using or converting Lambert coordinates in D3
- How can I implement 508 Compliance (like Aria) for a Timeline Slider made with D3.js?
- d3 custom order bar series with two categories
- How does text on SVG not update but text on a div does?
- D3: Is there a simple way to enlarge a map statically?
- d3 graph has client's time zone instead of data's
- Pushing x and y values into array variables
- Creating graph with x-axis only using D3
- D3.js - Retrieving DOM subset given data subset
- Is it possible to get a list of Forces currently active in a D3 Force Simulation?
- d3 - Add single line to grouped bar graph
- D3.js create new array with nest() values
- Trouble installing with d3-context-menu with bower using VS code
- Text On each bar of a stacked bar chart d3.js
- d3.js realtime updating svg line with python websocket data
- SVG element from an array
- d3.js Combo chart Line and Scatter
- Animated sort stacked bar chart d3.js
- Chrome on Windows triggers d3.zoom behavior on click
- selectAll("g").data(data).enter().append("g") does not work?
- d3 example copied from website doesn't work on my computer
- Time axis in 24 hour clock
- D3.js - Transitions on a Streamgraph using CSV data
- d3 add text to SVG rect
- Why is nothing being displayed on the webpage?
- D3 force layout hover on arrow
- Why reset filter is not working in d3 js force directed graph?
- R Shiny HTML object is rendered on every tabPanel()