Ticks alignment in yaxis in chartjs - chart.js

I'm having some trouble with my right axis ticks with chartjs. You can see in the images I'm adding and removing different axis and it automatically puts them in the left or right side, but sometimes you can see that the numbers in the right axis are not aligned with the gridlines and sometimes they are aligned.
This just happens in the right side and you can see is not because of the information that it brings because there's an example in the images where I select one of the axis that has that error and put it to the left side (Hydrocarbon detector). I'm using Chartjs V2.7.2.
Can anyone help me with this issue please?
example with 6 axis, hydrocarbon to the right
example with 5 axis, hydrocarbon to the left
example with 6 axis, hydrocarbon to the left
example with 5 axis, hydrocarbon to the left

Related

Implement muti Y axis on QT chart?

I have to place 4 spines on the same chart with different Y ratios, so I need to set up 4 Y-axes.
I have read the "muti-axis" demo from QT creator, it shows a example of two Y-axis and the two Y-axis are put on left and right side.
It's good when there is only two spines,
but when I have 4 spines, how to relocate the 4 Y axis?
Is it possible to place the 4 Y-axis at the tick point of X-axis? like the image below.
I used ChartJs2QML for displaying charts in QML.
Below is the approach I followed for multiple y axes. Maybe a similar approach can be adopted in Qt as well.
Show labels of all the y axes in the legend.
Show only one y axis by default. Hide all the other y axes.
On click of any y axes label in legend, hide the active y axis and show the clicked y axis.

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.

Mathematical Issue: Triangle, Pyramid, Rotation, Translation, Zoom

Another tricky question. What you can see here is my physical pyramid built with 3 leds which form a triangle in 1 plane and another led in the mid center, about 18mm above the other 3. The 4th one makes the triangle to a pyramid. (You may can see it better if you look on the right triangle. This one is rotated about the horizontal achsis, and you can see a diode on a stick very well).
The second picture shows my running program. The left box shows the raw picture of the leds (photo with ir-filter). The picture in the center shows that my program found the points and is also able to tell which point is which, based on some conditions (like C is always where the both lines with maximal distance betweens diodes intersect; and the both longest lengths are always a and b). But dont care about this, i know the points are 100% correctly found.
Then on the right picture are some calculated values, like the height between C and c and so on. I would be able to calculate more, but i didnt bother to care for now, cause I am stuck.
I want to calculate the pyramids rotation and translation in the 3 dimensional space.
The yellow points are the leds after rotation arround an axis throught the center of the triangle in camera z- direction. So now i do not have to worry about this, when calculating the other 2. The Rotation arround the horizontal axis, and the rotation arround the vertical axis. I could easily calculate this with the lengths of the distance from the center of the triangle to the 4th diode (as you can see the 4th diode moves on the image plane with rotation), or the lengths of the both axes.
But my problem is the unknown depth.
It affects all lengths (a,b,c, and also the lengths from the center to the 4th diode if we call this d and e). I know the measurments of the real pyramid, with a tolerance of +-5% or so, but they get also affected by the zoom. So how do i deal with this?
I thought of an equation with a ratio between something with the lengths of the horizontal axis, the length of the vertical axis, the angles alpha, beta and gamma, and the lengths d and e.
Alpha, beta and gamma only get affected by rotation arround the axes (which i want to know. i want to know the rotation and the zoom), where a rotation arround one axis has the opposite effect than a rotation arround the other. So if you rotate arround both axes in the same angle, the ratio between the length of the axes is the same as before.
The zoom (real: how close it is to the camera; what i want to know in 1st place: multiplication factor 2x, 3x,0.5, 0,4322344,.....) does not affect the angles, but all the lengths: a,b,c,d,e,hc (vertical length of axis), hx (i have not calculated it yet, but it would be easy. the name hx can vary, i just thought of something random right now; it is the length of the horizontal axis) in the same way (i guess).
You see i have thought of many, but i think i am too dumb.
So, is there any math genius out there wo can give me the right equations, for either the rotation OR/AND the zoomfactor?
(i also thought about using Posit/Downhill- Simplex, and so on, but this would be the nicest, since i already know so much, like all Points, and so on and so on)
Please, please, i need your help really bad! I am writing this in C++ and with help of OpenCV if you need to know, but i think its more a mathematical problem.
Thanks in advance!
Ah, and Alpha seems to be always the same as Beta!
Edit: Had to delete the second picture
Have a look to Boost Geometry or here also
Have a look at SolvePnP() in OpenCV. Even if you don't use it directly, the documentation has citations for the methods used.

Finding Top Left and Bottom Right Points (C++)

I'm looking for some help with a project I'm working on.
What I'm doing is a polygon approximation algorithm. I've got all of the points of my boundary, but in order to start the algorithm, I need to find the top left and bottom right points from the set of points. All of the points are stored in a structure array that has the x and y coordinates of each point. Any ideas on an easy way to loop through the array of points?
Any help would be greatly appreciated. If you need more information, just ask and I'll provide all I can.
Based on your comment that bottom left is min(x+y) and top right is max(x+y)
Top left: min(x+max(y)-y)
Bottom right: max(max(x)-x+y)
Where the inner max is a constant.
Though this may not always give a result that agrees with your eyes.
Alternative metrics can be constructed based on the distance from the corners of the bounding box of your object, or the square of the distance, etc.
Another technique is to translate the polygon around the origin and then top left is the point furthest from the origin but in the top left quadrant... That gives a whole heap of choices as to where to put (0,0) could be average of all, could be weighted average based on some rule, etc. lot of variability in how you pick that, each may give results that differ for a very small number if polygons from what the eye would pick.
Finally you could always train a neural network to pick the answer.... That might result in something that is (insert confidence limits from training)% likely to give an answer you agree with... But you and I may disagree
Top left: min(x+max(y)-y)
Bottom right: min(max(x)-x+y)
Where the inner max is a constant.
For the corners I used 2 indicator variables left and up which can have the values {-1,1}.
For upper corners (i.e. top-Left and top-Right) up := 1,
if its a lower corner (i.e. bottom-left and bottom-right) up:= -1 .
Analogously for the left variable:
left:= 1 for top-left and bottom-left
left := -1 for top-right and bottom right
Then the corner can be found by maximizing the term
left * point.x + up * point.y
over all Coordinates.

How to determine if mouse is moving clockwise or counterclockwise?

I have an MFC appplication where the user have to move the mouse around a circle circonference with a dragging mouvement. I need to retrieve the number of degrees during this mouse drag "rotation" and I need to know if it's clockwise or counterclockwise.
At first, to determine the rotation direction, I was comparing x-coordinnate between the current mouse position and the mouse position where the user clicked to initiate the dragging. That works well until the user rotate over 180 degrees.
How can I handle the other half of the circle?
You'll need at least three ordered points to determine whether someone is moving clockwise or counterclockwise over time. With only two points, it isn't obvious whether (for instance) someone rotated 90 degrees or -270 degrees. So simply taking the cross product of the start and end won't work.
Try sampling the mouse during the dragging to get the additional information you need, and then taking incremental cross products between each pair of consecutive points. That will tell you what you want to know. However, you'll need to sample fast enough that no rotation of more than 180 degrees could have occurred; otherwise you'll wind up in an ambiguous situation again.
These might help you.
http://en.wikipedia.org/wiki/Atan2
http://www.phy.syr.edu/courses/java-suite/crosspro.html
And here is a simple example of recognizing gestures (it's in flash but the idea is the important bit)
http://www.bytearray.org/?p=91
Read about cross products. Computing a cross product between the X and Y vectors (differences from the start point) will always reliably give the rotation direction.