ChartJS - adding scroll to horizontal legend in Line chart - chart.js

I am creating project with ChartJs, and I am fetching real time data from the server. Each second, I add extra data point. After some time, there is just too many points on the graph, to the point that you cannot see anything. I would like to know, if there is a way to scroll through the x-variables, and always have set distance between the points? As of know, the distance between points is shrinking, making the graph not readable.
Thanks!

I would like to know, if there is a way to scroll through the
x-variables,
You can use .removeData( ) to remove the (current) first set of points. This would keep only the same number of (latest) points visible on the graph.
...and always have set distance between the points?
Unless you remove points maintain a set distance while adding points would cause the graph width to increase - which is usually not what you want to do.

Related

Set points outside plot to lower and upper limit

Maybe this question exists already, but I could not find it.
I am making plots in Python. I don't want to set my axes range such that all points are included - there are some really high or really low values, and all I care about in those points is that they exist - that is, they need to be in the plot, but not on their actual value - rather, somewhere on the top of the canvas.
So i found something that helps a bit in achieving what i want to do in this question Link
So basically this thing works:
xmax=0.18
plt.(np.minimum(x,xmax),y)
But when I tried something like this then it didn't work.
xmin=0.8
xmax=0.18
plt.(np.minimum(x, xmin,xmax),y)
How can i solve this?
To force the points above a threshold to a maximum level you may use np.minimum(x,xmax).
To force the points below a threshold to a minimum level you may use np.maximum(x,xmin).
To do both you may combine the two commands
xlimited = np.minimum(np.maximum(x,xmin),xmax)
Note that to have the points restricted in the vertical direction you would do this to the y values of course.

OpenCV Merge point clusters, remove outliners

I want to determine the point where most lines from the image cross. Obviously, there can be more than one such point, but for simplicity I'm trying with just one point for. I was trying with OpenCV built in Kmeans clustering, but this algorithm assumes every point must be clustered, so I get something like this:
Obviously it gets much worse when more lines are present as every intersection will offset the center of the cluster
What I want to accomplish is removal of all the outliners that come as a result of accidental line crossing here and there which is especially problematic in complex scenes.
I was thinking of DBSCAN but it appears I'd need to implement it myself from scratch since it's not present in OpenCV - I'd prefer not to spend extra time on something that's not a core part of my project and focus on the topic instead of making tools. Is there a library that can do what I need? Alternatively I was considering brutal force in form
for each point in list
find nearest neighbor
if distance > threshold
label as bad
if point already has label AND neighbor already has label
two sets collided, merge them
else if neighbor already has label
assign point.label = neighbor.label
else
point.label = new Label
neighbor.label = point.label
find mass center of each labeled set and replace set with it's center.
You can use Sklearn library in python. It has many other algorithms
http://scikit-learn.org/stable/modules/generated/sklearn.cluster.DBSCAN.html

line-trace tooltip along x-axis?

In v2.0-beta, is there a way to configure the tooltip corresponding to that x-position to show up when hovering anywhere above that point on the axis? for example, the functionality shown here:
https://blockchain.info/charts/market-price
As you trace the line horizontally, you are shown the tooltip corresponding with your distance from the y-axis.
What the tooltip shows in your example is the y value corresponding to the distance from the y-axis (i.e. the x value).
Unless you want to extrapolate between data points (not usually a good idea for data like that shown in your example, since you don't know that its going to follow your extrapolation), this means that you need to have data values for all points where you want to show the tooltip.
With that your question is basically about showing every n x axis labels. https://stackoverflow.com/a/31606933/360067 does this similar for the current stable version of Chart.js. For v2.0-alpha, the option you need to be adjusting is scales.xAxes.labels.template.

Minimum distance between markers

Each red circle in this map is a point but due to the density of them, there isn't enough space to show the text labels for all of them. So I want to filter them down to just show those which can show a text label.
How can I do this? marker-spacing seemed to be promising but makes no difference. I see no "marker-min-distance" as there is with "text-min-distance".
Basically there's no point in showing a marker at all if it can't be identified with text. This is for a non-interactive offline map.
There is marker-spacing.
If you want to draw only labelled markers, use shields instead (answered here).

How to verify if the user draw a line over a collection of points in cocos2d

I am doing alphabet tracing application for kids. I have given the dotten points. how to identify that am moving over that points. using Touches moved, i want to write.If moved incorrectly, i dont like to draw lines. plz share ur ideas
The simple version is:
Record the initial touch-point on touchesBegan.
On each touchesMoved call, do:
Interpolate a reasonable number of points (a dozen or so should be sufficient) between the initial touch-point and the current touch-point.
For each interpolated point, perform a hit-test against your "dot" locations. This can be done by computing the linear distance between the point and the "dot" location, and counting any distances closer than some threshold as a "hit".
Set the initial touch-point to the current touch-point.
On touchesEnded, perform one final round of interpolation and hit-test, and then clear your initial touch-point.
Of course you may want to add some extensions of your own to the basic algorithm, such as keeping an array of all the contacted points to check at the end of the event to help discriminate coordinated interactions from random nonsense, and so on.