Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » ScatterDraw & ScatterCtrl » Ideas: Grid lines at "round" dates or values. More options for tooltip.
Ideas: Grid lines at "round" dates or values. More options for tooltip. [message #51787] Thu, 30 May 2019 12:07 Go to next message
Maginor is currently offline  Maginor
Messages: 17
Registered: May 2019
Promising Member
Hi,

I have come across a few things that I think could be improved for scientific plotting. I respect that this project is done on people's free time, I am just throwing in some ideas that are of course just my opinion.


I have a graph of daily values. I can use grid unit formatting to get the X axis to display the dates just fine. However, my problem is that the grid lines show up at fairly "random" places. For instance, if I zoom out far enough, I want the grid lines to be at Jan. 1st of every year, but if I zoom in more, I want them to be at the 1st of each month etc (whatever more closely fits the desired amount of grid lines). There could also be some steps in between such as showing a line each half year or each quarter year when appropriate.

This is a graph that the user can freely zoom around in, so it has to be able to update this dynamically.

There does not seem to be any native support for this, and the only way I can see to set the grid lines is by setting their beginning, spacing and count. This will not work for this purpose since Jan. 1st of each year is not equally spaced because of leap years, and similarly months are not equally spaced.


Moreover, I sometimes have data series of just monthly or yearly values, and in those cases I would like the grid lines (of the X axis) to be only where there are data points, never in between.


Another thing I am looking for is that I would like to tell the plot to try to snap grid lines to round values as a default. I.e. I want lines at (0.25, 0.5, 1, 1.25, 1.5, 1.75) rather than (0.05, 0.67, 1.3, 1.92) even if my Y axis happens to range from (0.05 to 1.92). This is something I can do myself just by doing some computations, so it is not a big deal, but it would be nice to have it as an option.


Another thing (Sorry!!):
The tooltip (SHOW_INFO action) in ScatterCtrl shows the x and y position of the cursor. I would like an option for it to show the y value of the graph at that x point (i.e. show (x, f(x)) rather than (x, y)).

If there are multiple graphs, I'm not sure how that should be handled, but maybe either show a list of the values of all the graphs or just show the value of the closest graph to the cursor.
If it is a scatter plot rather than a continuous line plot, it would maybe be good to show the value of the closest point on the graph. Similarly, for bar plots it would be good to show the values of the closest bar.


Again, I am very thankful that this library exists at all. I am just throwing in some ideas.

[Updated on: Thu, 30 May 2019 12:12]

Report message to a moderator

Re: Ideas: Grid lines at "round" dates or values. More options for tooltip. [message #51790 is a reply to message #51787] Thu, 30 May 2019 16:44 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 2979
Registered: August 2008
Veteran
Hello Maginor

Thank you, all your comments are valid.

You propose interesting features. Some of them can be solved using cbModifFormat* callbacks, but not all. A feature I have never known how to do it is a general and precise zooming algorithm: advices are really acknowledged!

Other feature always waiting to be implemented has been to choose series and series points with a mouse click. If you need this, It will be implemented.


Best regards
Iñaki
Re: Ideas: Grid lines at "round" dates or values. More options for tooltip. [message #52229 is a reply to message #51790] Mon, 12 August 2019 16:11 Go to previous messageGo to next message
Maginor is currently offline  Maginor
Messages: 17
Registered: May 2019
Promising Member
I think all my problems with irregular spacing of grid lines would be solved if I could set grid lines explicitly instead of just min, and unit.

So for instance there could be functions

ScatterCtrl& SetGridLinesX(Vector<double>& GridLinesX);
ScatterCtrl& SetGridLinesY(Vector<double>& GridLinesY);


And then inside the WhenZoomScroll callback, I could just compute the grid lines I want myself and set them using these functions.


I'm not sure what you mean by a zooming algorithm. In what sense?
Re: Ideas: Grid lines at "round" dates or values. More options for tooltip. [message #52240 is a reply to message #52229] Tue, 13 August 2019 21:45 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 2979
Registered: August 2008
Veteran
Hi Maginor

The problem with zoom is that the grid spacing would have to be adequate with different zoom levels and scroll. From example:
- If X goes from 0 to 10, spacing could be every 2 (2, 4, 6, 8 )
- If X goes from 321 to 501, spacing could be every 40 (361, 401, 441, 481)... or adjusted to more rounded values, every 50, like (350, 400, 450, 500)

Maybe as an intermediate solution, we could add something similar to that you propose, although, instead of returning a Vector<double>&, I would propose to add a callback returning Vector<double>&, with the values of the grid positions adequate to that level of zoom.

What do you think?


Best regards
Iñaki
Re: Ideas: Grid lines at "round" dates or values. More options for tooltip. [message #52241 is a reply to message #52240] Wed, 14 August 2019 09:38 Go to previous messageGo to next message
Maginor is currently offline  Maginor
Messages: 17
Registered: May 2019
Promising Member
Yes, I think that is a good idea. With custom grid lines you definitely need to update them at every change in zoom level any way, so that would do what I need it to.
Re: Ideas: Grid lines at "round" dates or values. More options for tooltip. [message #52246 is a reply to message #52241] Thu, 15 August 2019 20:00 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 2979
Registered: August 2008
Veteran
Hello Maginor

They are already included and documented, but I have not had time to include them in an example. Please test them:
	Callback1<Vector<double>&> SetGridLinesX;
	Callback1<Vector<double>&> SetGridLinesY;


Best regards
Iñaki
Re: Ideas: Grid lines at "round" dates or values. More options for tooltip. [message #52248 is a reply to message #51787] Fri, 16 August 2019 09:32 Go to previous messageGo to next message
Maginor is currently offline  Maginor
Messages: 17
Registered: May 2019
Promising Member
Thanks a lot! I will test them now.
Re: Ideas: Grid lines at "round" dates or values. More options for tooltip. [message #52249 is a reply to message #51787] Fri, 16 August 2019 11:35 Go to previous messageGo to next message
Maginor is currently offline  Maginor
Messages: 17
Registered: May 2019
Promising Member
Hi, it almost works now. It is correct initially, but when I pan the plot sideways the grid lines slide in the wrong direction, while the text reticles are correct (and so become unaligned with the grid lines).

As far as I can see from the code in ScatterDraw::Plot, it seems like the grid lines are drawn with reference to the right of the plot instead of the left?

Here is an example callback where this happens.
void PlotCtrl::UpdateDateGridLinesX(Vector<double> &LinesOut)
{
	//InputStartDate is X=0. X resolution is daily
	
	double XMin = Plot.GetXMin();
	double XRange = Plot.GetXRange();
	
	Date FirstDate = InputStartDate + (int)XMin;
	int FirstYear = FirstDate.year; //+1?
	Date LastDate = FirstDate + (int)XRange;
	int LastYear = LastDate.year;
	
	Date IterDate(FirstYear, 1, 1);
	for(int Year = FirstYear; Year <= LastYear; ++Year)
	{
		IterDate.year = Year;
		double XVal = (double)(IterDate - InputStartDate) - XMin;
                if(XVal > 0 && XVal < XRange)
		        LinesOut << XVal;
	}
}


(Plot is a ScatterCtrl, InputStartDate is just a reference date for X=0).
Re: Ideas: Grid lines at "round" dates or values. More options for tooltip. [message #52250 is a reply to message #51787] Fri, 16 August 2019 12:21 Go to previous messageGo to next message
Maginor is currently offline  Maginor
Messages: 17
Registered: May 2019
Promising Member
When I edit ScatterDraw::Plot so that grid x positions are computed in the same way as reticle positions, then things work correctly.
Re: Ideas: Grid lines at "round" dates or values. More options for tooltip. [message #52253 is a reply to message #52250] Sat, 17 August 2019 22:53 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 2979
Registered: August 2008
Veteran
Sorry Maginor

X axis zoomed badly. Please check it now.


Best regards
Iñaki
Re: Ideas: Grid lines at "round" dates or values. More options for tooltip. [message #52254 is a reply to message #52253] Mon, 19 August 2019 10:21 Go to previous message
Maginor is currently offline  Maginor
Messages: 17
Registered: May 2019
Promising Member
Thanks, it works now!

I't awesome that you were this quick to implement the new feature! I can get exactly the behavior I want out of the graph now.
Previous Topic: [Bug] Text overflows legend box
Goto Forum:
  


Current Time: Tue Aug 20 01:06:43 CEST 2019

Total time taken to generate the page: 0.03661 seconds