javascript - d3 brush and setting minimum tick marks with a time scale -


edited

For 'context'

Without worrying about setting the minimum, I successfully implemented a multi series chart with context and focus.

The problem occurs when the limit may be small enough to show hours on the dynamic focus chart when the brush is small enough.

My question is whether it is possible to set the minimum tick mark or brush can be reduced to restrict that amount to ensure that tikkas do not go for hours, but these days Are limited?

The following code sets the minimum tick, but no matter how big the brush is, the way to appear in this way can also be the number (day).

  function brush () {removeFixedLine (); Var newData = brush.empty ()? X2.domain (): brush.extent (); X.domain (newData); // Radra Tooltip X-Focus Focus .selectAll ("dot") .attr ("cx", function (d) {return x (d.date);}); // Focus radraw lines. Select all ("Path Path"). Ether ("d", line); MinExtent = d3.time.day (brush.example () (1)) - d3.time.day (brush. Treatment () [0]); Console.log (minExtent); Var newxaxis = xaxis; If (Minnext> 8640000) {xAxis.ticks (d3.time.days, 1); Focus.select ("x.axis") call (xAxis). } Other {focus.select (".x.axis"). Call (newXAxis); }}  

Note: This code has been edited and massaged, sometimes it can not be fully understood, but the summary of what I want to achieve should be summarized.

When a user is manipulating the user, you will see a certain minimum limit , But you can add a check to your brush function to see if the range is too small, and if it is set to its lowest value:

  var minExtent = 8640000; Minimum millisecond / numeric brush to display in the Focus Chart function () {removeFixedLine (); If (brushmate ()) {x.domain (x2.domain ()); // Reset domain (note typo fix!)} Else {var newData = brush.extent (); Var width = new data [1] - new data [0]; // It considers a single direction brush, // if in the original code (width  

Note that there are three things that should be modified by you The limit has been applied:

  • Set the extent to using the brush object;

  • Use the brush's SVG rendering again

  • or selection.call (brush) (which is the exact same thing, just written in a different way);

  • You usually want to set the Focus Chart X-Scale domain.


Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

c# - MySQL Parameterized Select Query joining tables issue -