Using amCharts5 is there a way to snap the dateAxis visible min and max to the nearest data item \ baseInterval \ groupInterval? - amcharts

I'm trying to find a way to snap the xAxis in a line chart to the closest min and max data points in the visible chart area.
As you can see in any of the line chart demos, when zooming or panning the chart, the start and end position of the chart will not snap to the nearest data item (i.e. day, or month when grouped etc.). After zooming or panning the chart, the start\end of the chart area will be at some point based on where you zoomed or panned, but very difficult to land it exactly on the interval.
I'd really like to figure out a way to snap the min and max position of the visible chart area to the nearest min and max data points, ideally using short but smooth animation to snap once the zoom\pan event is finished\released.
I figure this is possible somehow by using something like the DateAxis zoomToDates method after a zoom\pan event is triggered, but haven't been able to find a way to do it.

Related

How to set the radiuses of each band on a sunburt chart?

I'm using the new sunburst chart for a 2 level hierarchy [country,region] and it works great, but I have one issue:
the second band (region) is tiny compared to the first one (country). How to adjust the radius to it works better visually?

D3: Brushing already zoomed data

I am trying to implement zooming and Linking&Brushing in Bubble chart.
Aplaying linking and brushing while data are still on initial position works just fine. Also zooming alone works just fine.
But if I zoom the chart and then i try to select the data, then it's not selecting the right ones.
Example:
Brushing while zooming is not applied
Bushing after zooming was applied
I am using brush.extent() to get the position of brushing space. Somehow the position of dots is never updated, while zooming.
I can take under consideration the scale size while I am brushing. But I am asking if there is something which updates the dots position after zooming automatically. Or am I missing something as I am pretty new at using d3.js and also on visualization field.
If anyone is facing the same error, maybe my solution will be helful.
While brushing I add the translate values to the x and y coordinates.
d3.event.translate

D3.js zooming and panning - lock on y axis

I'm trying to build a stock chart with zooming functionality using D3.js
I'm looking to start with this example here and attempt to make the zoom feel more natural for a stock chart. A perfect example is this. So the difference as far as I understand is that zoomng and panning are both locked on the Y-axis, and the only way the Y-axis moves is to autmatically fill the price range of the currently visible data.
Another noticeable difference is that zooming does not zoom into the current position of the mouse like it does in the first example.
How can the example be adjusted to work more closely as the other chart? What is the pertitent code, how should it be changed?
Setting the zoom behaviour to not affect the y-axis is simple: just don't attach your y-scale to the zoom behaviour.
In the sample code you linked to, the zoom functionality is added in this line:
this.plot.call(d3.behavior.zoom()
.x(this.x)
.y(this.y)
.on("zoom", this.redraw() )
);
That creates a zoom behaviour object/function, links it to the graphs x and y scales, and tells it to call the function returned by this.redraw() after every zoom event. The zoom behaviour automatically changes the domain of the scales on zoom, and then the redraw function uses the modified zoom. If you don't give it a y scale to modify, then zooming won't affect the y domain.
Getting the y scale to automatically adjust to the given extent of the data is a little trickier. However, remember that the zoom behaviour will have automatically adjusted the domain of the x scale to represent the extent of visible data horizontally. You'll then have to get the corresponding slice of your data array and figure out the extent of y values from it, set your y domain accordingly, and then call the redraw function (remembering that this.redraw() just returns the redraw function, to call it within another function you'll need to use this.redraw()() ).
To have the zoom be independent of the mouse position, set a center point for the zoom behaviour.

Zoomable scatter chart

In Qlikview 11 I managed to set up (amongst others) a nice scatter chart without any major problems. Now I would like to be able to zoom into a region in that chart. Intuitively this could be accomplished by selecting a rectangular region with the mouse. Incidentally this works fine in "regular" line or bar charts. The new x and y axis regions correspond to the selected rectangle. However this does not happen with my scatter chart. I suspect this has something to do with the way dimensions are handled in scatter charts. For easier understanding I appended to screen-shots of the status quo - or how I don't want it to be.
Full chart with selected region http://img801.imageshack.us/img801/4873/6ccc.png
Chart displaying only the selected data http://imageshack.us/a/img138/9053/kck5.png
From what it looks like, I would guess that the scatter plot has hard coded axis max and mins. Check the "Axes" tab under chart properties, and uncheck the scale boxes. That should allow the chart to zoom in.

jqPlot axis with ticks labeled differently from underlying data

So I am using jqPlot to display distance (y-axis) over time (x-axis) in a simple line graph.
However, while I have actual distances as the underlying data used to position the points, I'm not interested in displaying those distances on the y-axis.
Instead, there are a series of landmarks at given distances, that I want to appear on the y-axis as a 'tick' next to the appropriate point for the distance to that landmark. That way the line appears to "pass" each landmark as it travels upward.
Currently I'm "faking" this by hiding the ticks and putting a manually-created series of labels next to the graph. This works well enough, but I had to disable vertical zooming because if the user chose to zoom in, the labels would not match up with the actual distances. My users would really like to zoom in vertically, however, and I want to allow them to.
Therefore, does anyone know of a way (a plugin or similar) that would allow me to associate custom labels with given tick marks in jqPlot, that will match up nicely and respond to zooming? It would be necessary to hide some of the landmarks if the graph is zoomed out too much, so that would have to be a feature.
Alternatively, if someone knows of a "zoom event" that passes in the min and max y values, I could probably recreate my manual labels with that data, so let me know if you know of a way to get that information. I haven't been able to find one.
I would need to see a bit of your code to customize it to the distance but to start with you could label the ticks and it will display over the size of the chart.
axes:{yaxis:{ticks:['DiscanceA','DiscanceB', 'DiscanceC', 'DiscanceD', 'DiscanceE'],
renderer: $.jqplot.CategoryAxisRenderer,},
Let me know how it goes and if you have any code lets see it!

Resources