User (Legacy) Posted March 31, 2004 Report Share Posted March 31, 2004 Hello! I'm having problems with the AutoSize property for the series legend box. Sometimes the legend box is automatically resized to fit the contents, and sometimes - not. I'm using the latest version of Chart FX Client Server DLL. I have created a small sample app - see the attached zip (it's an MFC app created under VC++ 6). Chart-related code is located in MyView.cpp. The zip also includes a sample chart file, sample.chd. Please perform the following steps to repeat the problems. - Start the program. Its window's size is 800x600. - Open sample.chd file - The legend box at the bottom should contain 4 labels in a single row (gregtest, pmntest99, sw-sys..., test2) - Note the legend box has AutoSize = True Everything is fine up to this point. - However if you decrease the width of the window (say 2 times) you will see that some labels just disappear from the legend box. I would expect the legend box to be auto-resized to fit contents, i.e. it should be 2 lines. And this is the problem #1. - Right click the legend box and turn AutoSize off. - Right click again and turn AutoSize back on. Now the legend box is "fixed", i.e. 2 lines as expected. - However if you make the window wider again the legend's height will remain 2 lines though the labels are drawn as a single line. And this is the problem #2. - Again, right click the legend box and turn AutoSize off. - Right click again and turn AutoSize back on. The legend box is "fixed" again, i.e. a single line as expected. - Now select File - Test Paint() menu item. This will open a new window with its background 'painted' with a chart picture. The picture is created using the Paint method. - The legend box is wrong again as only 3 labels of 4 are shown. This is the problem #3. Is it a bug or a problem within the chart file? How can I make the legend box display _all_ labels? I mostly interested in the problem #3 with the Paint method because I have found a solution for #1 and #2. My workaround is to call SizeToFit method on WM_SIZE (though I believe the library must do this automatically). However SizeToFit doesn't seem to help with the Paint method problem. Any advice? Thanks in advance, Serge Link to comment Share on other sites More sharing options...
Software FX Posted April 1, 2004 Report Share Posted April 1, 2004 This is by design. In Chart FX 5.x the legend box does not resize itself when the chart is resized. AutoSize means the legend will adjust its size when it is created using its contents. What you can do this in your OnSize method, you can call: m_pChartFX->SerLegBoxObj->SizeToFit(); As a new feature in Chart FX 6.x, the legend is automatically resized when the chart size changes. -- FP Software FX Link to comment Share on other sites More sharing options...
User (Legacy) Posted April 1, 2004 Author Report Share Posted April 1, 2004 Thanks. It's OK for me to call SizeToFit() in OnSize method. But what about the Paint() method? SizeToFit() doesn't seem to affect it. For example, if I want to draw a chart image into a device context I do the following: CDC dc; ...create/obtain DC here... CRect rect; ...image rect... (**) m_pChartFX->SerLegBoxObj->SizeToFit(); m_pChartFX->Paint( (long)dc.m_hDC, rect.left, rect.top, rect.right, rect.bottom, CfxChartPaint(CPAINT_BKGND|CPAINT_PRINT), NULL); Regardless of whether (**) line is present or not the produced image contains an incomplete legend. You can see this from my sample app. Just start it, open sample.chd and select File - Test Paint() menu. I' also attaching a screenshot. How can I make the Paint() to draw the __full__ legend box? Is there any setting for this? Serge Link to comment Share on other sites More sharing options...
Software FX Posted April 2, 2004 Report Share Posted April 2, 2004 The only way to achieve this in Chart FX 5.x would be to Resize the chart to the same size you are going to use in Pain, call SizeToFit on SerLegBoxObj, and then call Paint. -- FP Software FX Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.