Skip to main content
Announcements
Qlik Connect 2025: 3 days of full immersion in data, analytics, and AI. May 13-15 | Orlando, FL: Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Identify repeatable dots on the scatter diagram

We are creating a scatter diagram with x & y coordinates to identify the surface marks on glass. If the number of dots within the range the 5 pixels is more than 5 then i need to display the alarm mark on the same scatter diagram. How can we plot this kind of graphs using qlikview.

can you please let me know the solution for this problem asap?

many thanks.

12 Replies
vgutkovsky
Master II
Master II

I don't think this is possible in QV. As far as I know, you can't replace the symbols in a scatter chart. Even if you could somehow manage that, replacing them dynamically would be impossible. However...as of version 10, you can create custom AJAX objects called "QlikView Extensions." In these extensions, you can define a custom chart that will behave however you want. If you need this functionality outside of AJAX, you would need to write a custom OCX object instead of an Extension.

Regards,

johnw
Champion III
Champion III

I assume it's not really pixels that you care about, as resizing the chart and so on doesn't seem like it should affect whether or not there's a problem deserving an alarm. I assume the marks would be within a certain distance of each other in X & Y terms.

My goal, I think, might be to handle it with color and possibly size. So all the normal marks might be small and gray, but any group of 5 or more in a specific area would turn bright red. Now the trouble is calculating distance. The distances to check are basically the square of the number of points, so let's hope you don't have a large number of points!

I'd calculate distances in the script rather than on the fly in the chart. Then, for each point, I'd count the other points that are close. I'd set a flag based on that count, or possibly just store the count. If you don't need the distances for anything else, drop them.

OK, this sounds doable. I'm going to try it.

OK, see attached application. I'm not sure it's QUITE what you want, in that you could have five points that would fit inside a circle of diameter 5, but none of the points have four other points in that distance. I'm not even sure how you'd go about testing every possible circle of diameter 5, though. There's probably some advanced mathematics way of doing it in a reasonable time frame, but I'm not a mathematician.

Oleg_Troyansky
Partner Ambassador/MVP
Partner Ambassador/MVP

If your data is relatively small, you could try to create a solution in your load script. Something along those lines:

1. Create all possible permutations of 2 "dots" - in essence, a "Cartesian multiplication" of the array of all the dots, multiplied by itself (this is why it only works for small volume of data).

2. For each pair of dots, calculate the distance between the dots = Square root of ( (X1-X2) ^ 2 + (Y1-Y2) ^2 )

3. Reload this table, using GROUP BY, counting the number of "secondary dots" per each "primary dot", where the calculated distance is less than 5

4. Store the counts for each dot.

5. In your scatter chart, color all the dots with a neutral color, and use RED color to emphasize those dots with the count > 5

something like this should work if the size of the data allows...

johnw
Champion III
Champion III

Apparently Oleg and I are in psychic communication. Smile

Anonymous
Not applicable
Author

Thanks for your quick reply John.

If we had written logic on data loading scrips then it will effect the performance of data load time because we are working on millions of records. This calculation logic will be shown on the scatter diagram after applying certain filters. Based on the picture on the diagram, i want to designate the thickly populated dots based on this logic. Is it possible?

Oleg_Troyansky
Partner Ambassador/MVP
Partner Ambassador/MVP

John - this was funny.

Bhami - if you know a way to calculate the distances between all possible dots in the chart, then you can use that condition in determining the dot's color. I can't say that I know an easy way of doing it.

Also, your selections must reduce the data down by A LOT, to enable this kind of calculation in real time.

johnw
Champion III
Champion III

Easy enough to do the exact same calculation in the chart as in the example. Create a data island to hold a copy of the points and coordinates. Count up the points from the island table in range of the real point. If >=5, color it red and make it bigger. Same basic idea, just in the chart.

QUALIFY *;
[Island]: LOAD * RESIDENT [Points];
UNQUALIFY *;

background color expression: if(count(if(pow(X-Island.X,2)+pow(Y-Island.Y,2)<6.25,Island.ID))>=5,argb(120,255,0,0),argb(120,0,0,0))

z expression: if(count(if(pow(X-Island.X,2)+pow(Y-Island.Y,2)<6.25,Island.ID))>=5,5,1)

Example updated with that.

As Michael says, the more points, the longer this will take to render. You might experiment with performance. If you find that anything over 1000 points causes a serious problem, then set that up as a calculation condition for the chart. Or maybe put a button on the screen that tells them the number of records and estimates the time required to display the chart, and they click it to make the chart display. If they WANT to wait for 5 minutes to see the chart, why stop them? Just make sure they know what they're getting into first. Then probably set it up so that any change in selections removes the chart again. You could handle that by, when they click the button, running a macro that records the current selections. Something like this:

set field = activedocument.variables("vSelections")
field.setcontent activedocument.evaluate("getcurrentselections()"),false

Then for the display condition for your chart, something like this:

getcurrentselections()=vSelections

Seems like it would work. They click the button, it records the current selections, they therefore match the current selections, so it shows the chart. Hit clear, change a selection, anything like that, and the current selections will no longer match the variable, so the chart should go away again.

johnw
Champion III
Champion III

I've updated the example with the button approach I mentioned. I've also given a very different solution, using a pivot table to count the number of points within certain ranges. It's not an ideal solution, as you could have a lot of points close together that fall into different classes and thus don't count as a cluster. The main advantage is that it should be very fast. I doubt it would meet your needs, though.

Anonymous
Not applicable
Author

John

Excellent solution. This is 100% solution that i am looking for. Many thanks for your help. It works.

regards,

Bhami