The MASM Forum

Projects => ObjAsm => Topic started by: Biterider on September 26, 2021, 07:05:59 PM

Title: Super fast Charts
Post by: Biterider on September 26, 2021, 07:05:59 PM
Hi
One of my current private projects required a more professional chart to display measured data.
A few years ago, I wrote PlotXY in a form that I could no longer use. I also was not very happy looking at the code so I decided to rewrite it but reuse some of the old code blocks.  :icon_idea:

An important goal was to keep it as performant as possible, as it has to render several thousands of lines and markers. It quickly became clear to me that, under these circumstances, it was taking too much time for the old code to render parts of the diagram that were not visible. For this reason, I implemented a new line-clipping algorithm, described here http://masm32.com/board/index.php?topic=9518.0 (http://masm32.com/board/index.php?topic=9518.0).

I wrote the code so that other chart types, such as bar charts, could be easily derived, reusing most of the common underlying infrastructure. The provided example in the attachment implements ChartXY, which is a series if (x, y) points, connected by straight lines.

I added code for gesture control, a general setup dialog, and some handy mouse interactions for moving and scaling the data. Use the left mouse button to drag the data, the scroll wheel to zoom in and out, the ctrl and shift keys and double clicking add more user functionality. The areas of the chart react differently to the interactions. All of these features can be enabled or disabled by setting some internal flags.
The input data type can be selected between REAL4 and REAL8 at compile time. All internal calculations are adjusted accordingly.

I compiled the code for 32 bit so that it can be viewed on machines that don't support 64 bit.
There may be a bug or two in the code, so feedback is welcome.

To recompile the code, some newer files are required, which will only be available in the GitHub repo until the next official ObjAsm release.

I will replace the old Demo07 with this new architecture and say goodbye to the older PlotXY.

Regards, Biterider
Title: Re: Super fast Charts
Post by: HSE on September 27, 2021, 05:34:21 AM
Hi Biterider!!

Look promissory  :thumbsup:

Perhaps only work in Win 10 or so, because here there is problems with maximization, no setup, no wheel, etc.  :biggrin:

Regards, HSE.
Title: Re: Super fast Charts
Post by: Biterider on September 27, 2021, 06:09:19 AM
Hi HSE
Thanks for testing. I'll look into it. Until then, i'll delete the exe from the first post.

Biterider
Title: Re: Super fast Charts
Post by: fearless on September 27, 2021, 01:00:57 PM
Maybe add a link to your github profile in your signature, just in case hosting is an issue at some future time, that way there is a reference to the ObjAsm repo as well.
Title: Re: Super fast Charts
Post by: Biterider on September 28, 2021, 02:48:18 AM
Hi fearless
Good idea, I'll change it right now  :biggrin:

Biterider
Title: Re: Super fast Charts
Post by: Biterider on September 28, 2021, 02:54:13 AM
Hi
I updated the first post with 2 executables.
The changes should address the repainting issue (wrong class sytles) nad the forwarding of the WM_MOUSEWHHEL message. Since Win10 has the option "scroll over inactive windows" activated by default, I didn't notice that a forwarding is necessary if this option is not activated or if the apps are executed on older operating systems..
Would be nice if you could check the apps again.

Thanks, Biterider
Title: Re: Super fast Charts
Post by: nidud on September 28, 2021, 03:39:31 AM
deleted
Title: Re: Super fast Charts
Post by: jj2007 on September 28, 2021, 04:02:43 AM
Quote from: nidud on September 28, 2021, 03:39:31 AM
The download is eaten by Windows Defender.

Jotti finds absolutely nothing (https://virusscan.jotti.org/en-US/filescanjob/dxyhz36p2y) - strange for a Masm executable  :tongue:
Title: Re: Super fast Charts
Post by: HSE on September 28, 2021, 05:11:11 AM
Hi Biterider!!

Tested in 32 bit:
Maximization is perfect now.
Wheel perfect now.
Setup only open in the bar where usually is title, but only after maximize mdichild.

Tested in 64 bit:
- 64 bit file:
    look perfect (wheel, selected tab in setup, etc,)
    just a minor issue in tab "General" in text name of colors (no visible surely because high contrast), no problem in others tabs.
- 32 bit file:
   Setup have same problem in all places. Look like setup is open but invisible, after press "esc" mdichild take focus again.

Regards, HSE.
Title: Re: Super fast Charts
Post by: Biterider on September 28, 2021, 05:55:40 AM
Hi HSE
Thanks for testing. I'll look into this issues.
QuoteSetup only open in the bar where usually is title, but only after maximize mdichild.
I'm not sure if I understand you correctly...

Biterider
Title: Re: Super fast Charts
Post by: HSE on September 28, 2021, 06:25:39 AM
Quote from: Biterider on September 28, 2021, 05:55:40 AM
QuoteSetup only open in the bar where usually is title, but only after maximize mdichild.
I'm not sure if I understand you correctly...
but it's very similar to english :biggrin:

If you activate "New" and you click in mdichild then no setup is visible.

If you maximize the newer child, then you can see setup, but only clicking in usual graphic title place.
Title: Re: Super fast Charts
Post by: Biterider on September 28, 2021, 06:48:23 AM
Hi HSE
I'm sorry my friend, now I get it. Sometimes it takes me a little longer to understand...  :biggrin:

Biterider
Title: Re: Super fast Charts
Post by: Biterider on September 29, 2021, 03:54:47 AM
Okay, next try.  :cool:

I think I found the problem with the setup dialog positioned on the screen.

I also looked at the high contrast issue and found something that really surprised me. Standard window controls somehow recognize whether they are on a white or black background and adjust the text color accordingly. How they do that is a mystery. I simply fixed the problem with the ColorButtons by always setting the text color to black, at least until I understood the logic.

The new binaries are in the first post.

Biterder
Title: Re: Super fast Charts
Post by: HSE on September 29, 2021, 05:06:43 AM
Hi Biterider!

Perfect now  :thumbsup:

Only legends are missing  :biggrin:

Here a picture of my rather primitive graphic to show legends (and title in same line to make economy of space)

Accidentally was captured the lecture of every point that I can make  :biggrin:
Title: Re: Super fast Charts
Post by: Biterider on September 29, 2021, 06:04:56 AM
Hi HSE
Legends are actually missing. In terms of coding, they are expensive because you have to precalculate all the individual sizes, then arrange them according to some predefined preferences (bottom, right, stacked, etc.) and then rearrange the other diagram elements to make room for the legend. I thought about using TextView to add additional text formatting. The same goes for the chart title.
Btw, the description text on the General tab is implemented using TextView.
But at the moment the code suits my needs.

Incidentally, the control is also prepared for a Y2 scale.

Maybe I'll borrow your idea for the cursor to read out chart values. I have an unused function key. Maybe I can activate this feature by pressing [ALT] and moving the mouse.  :thumbsup:

But first of all, thanks for testing.

Biterider
Title: Re: Super fast Charts
Post by: HSE on September 29, 2021, 09:21:05 AM
Quote from: Biterider on September 29, 2021, 06:04:56 AM
they are expensive because you have to precalculate.
Yes. I use title and legends because any application have only one object that make 5-30 graphics with 2-6 series each.
I fixed in that line. And more series, shorter the names :biggrin:.

I noted that, unlike ObjAsm32 version, it don't adjust margins when don't have axis titles.  :hmmm:

For sure I will have more ideas when I use the super fast chart   :thumbsup: 


PD: I almost forget that some weeks ago I maked several examples in the "Dark Side":  Crecimiento Animal II (http://www.prodanimal.com.ar/mod/model5.htm#10)
To change "complejidad" modifies number of series.
Title: Re: Super fast Charts
Post by: Biterider on September 29, 2021, 04:22:40 PM
Hi HSE
Very nice homepage.
The calculation model for the predictions appears to be complex. It all looks very professional. :thumbsup:

Biterider
Title: Re: Super fast Charts
Post by: HSE on September 29, 2021, 10:57:20 PM
Hi Biterider!

Quote from: Biterider on September 29, 2021, 04:22:40 PM
It all looks very professional. :thumbsup:
Thanks  :thumbsup:

Regards, HSE.
Title: Re: Super fast Charts
Post by: nidud on September 30, 2021, 12:07:22 AM
deleted
Title: Re: Super fast Charts
Post by: Biterider on September 30, 2021, 01:47:04 AM
Hi nidud
The only thing I did was changing some subroutines. It seems to me that a heuristic scanner detected a suspicious sequence of bytes and triggered a false positive result.
With the new compilation, this sequence is not there anymore and it passes the test.

Biterider
Title: Re: Super fast Charts
Post by: LiaoMi on October 01, 2021, 07:49:52 PM
Hi Biterider,

I have a strange effect, if you drag the graph, then it randomly changes the labels, is that how it should be?  :rolleyes:

Here's an example - https://i.ibb.co/GMpT7Xf/2021-09-29-14-17-38-Demo07.jpg

Thanks for the awesome implementation!  :thup:
Title: Re: Super fast Charts
Post by: Biterider on October 02, 2021, 03:07:28 AM
Hi LiaoMi
The scale labels are defined by the number of major divisions and minor divisions. They are set by the initial chart setup (in code) or the setup dialog. As you drag or zoom the data, the scales change automatically based on an algorithm to optimize the scale view, choosing the best combination of major and minor divisions.

Maybe it seems random, but there is a logic behind  :biggrin:

Biterider
Title: Re: Super fast Charts
Post by: FORTRANS on October 02, 2021, 05:50:31 AM
Hi,

   Windows 8.1 ran both versions.  They looked identical.
The program did not run on Windows XP.

Regards,


Steve N.
Title: Re: Super fast Charts
Post by: Biterider on October 02, 2021, 06:00:52 AM
Hi FORTRANS
Thanks, that sounds reasonable. The oldest supported operating system for this code is Win7.
You could probably make it compatible with WinXP by foregoing some APIs. Unfortunately, I no longer have XP available.

Biterider
Title: Re: Super fast Charts
Post by: LiaoMi on November 28, 2021, 09:21:45 PM
Quote from: Biterider on October 02, 2021, 03:07:28 AM
Hi LiaoMi
The scale labels are defined by the number of major divisions and minor divisions. They are set by the initial chart setup (in code) or the setup dialog. As you drag or zoom the data, the scales change automatically based on an algorithm to optimize the scale view, choosing the best combination of major and minor divisions.

Maybe it seems random, but there is a logic behind  :biggrin:

Biterider

Hi Biterider,

this means that this is such a feature, I observed in other statistical programs that only with a zoom does such an effect occur, and when dragging, all the designations remain in place. Then, in order to display all the labels, I need to move the mouse until the labels appear  :biggrin:

(https://www.funny-jokes.com/fun_pictures/cat_mouse_mat.jpg)
Title: Re: Super fast Charts
Post by: Biterider on November 29, 2021, 12:05:15 AM
Hi LiaoMi
Good to hear from you  :thumbsup:

Your description is correct. The method responsible for this behavior is ChartFlat.CalcScaleDivs. Based on the scale of min and max values, the number of decimal places, etc., it calculates the best combination. By "best" I mean the best for my particular application. I wrote this routine many years ago to visualize large measurement data series that I can zoom in to see some details and at the same time see the overall trend as I zoom out.
It is absolutely correct that it is not suitable for any other purpose. In this case this routine can be modified for a different behavior.  :cool:

Biterider
Title: Re: Super fast Charts
Post by: HSE on November 29, 2021, 10:42:51 PM
Hi Biterider!!

Original LiaoMi observation refer to existence of 2 different methods: one initially and other after you make some interaction.

Regards, HSE.