Results 1 to 3 of 3

Thread: Strange Chart Printing

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Feb 2018
    Location
    Texas
    Posts
    168

    Question Strange Chart Printing

    Hello All,

    Found this in the forum as a way to print a chart (MSChart) by copying the image to the clipboard and then printing the image.

    Code:
         MSChart1.EditCopy  
          Printer.PaintPicture Clipboard.GetData(vbCFMetafile), 0, 0, MSChart1.Width, MSChart1.Height
    I find that the image that is "printed" is not the image that shows on the screen. It is as if it wants to add to my X Axis. [See Attached Screen Grabs.] Hold on I got to resize ARG Great Wont allow uploads more that ust his one .. the original scale was set at 40

    What' happening? How to fix?
    Attached Images Attached Images  
    Last edited by clickman; Dec 3rd, 2020 at 08:45 PM.

  2. #2
    PowerPoster Arnoutdv's Avatar
    Join Date
    Oct 2013
    Posts
    5,910

    Re: Strange Chart Printing

    Maybe there are some clues in this external thread:
    https://microsoft.public.vb.winapi.g...ties-of-x-axis

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Feb 2018
    Location
    Texas
    Posts
    168

    Re: Strange Chart Printing

    Quote Originally Posted by Arnoutdv View Post
    Maybe there are some clues in this external thread:
    https://microsoft.public.vb.winapi.g...ties-of-x-axis
    Have taken a quick dive.. thanks so much for posting this. It looks promising..

    I have worked a "solution" thus far by adding a "dummy line" via an x-y array element to the charted data points. This is a 2 point line that extends to a positive X and positive Y and has the x-y value set in the code at a Form|Initialize ( Recall, I have X from 0 to positive numbers, and Y from 0 to negative numbers. This dummy line "plots" outside this range. I say "plots' because even though it is there, it does no show up in the chart at run time because it is outside the bounds area specified by my grid axis settings at design time and also at run time.)


    Code:
    Private Sub Form_Initialize()
    
    
    '< 255>
    '... these are values used to set the initial size of the X-Y grid scale
    'these are necessary to ge the pdf to print correctly
        
        int_X_ScaleValue = 40
        int_Y_ScaleValue = 60
    
    '</ 255>

    End Sub


    I then "plot this dummy line by initializing it"

    Code:
    Private Sub Initialize_CLineArray()
            '<EhHeader>
            'On Error GoTo Initialize_CLineArray_Err
            '</EhHeader>
    
    '...these are manulaly set at the frmLoad
    'int_X_ScaleValue = 40
    'int_Y_ScaleValue = -60
    
    
    100     CLineArray(1).X = 0
    102     CLineArray(1).Y = 0
    
    104     CLineArray(2).X = int_X_ScaleValue 'the 40 set at frmLoad
    106     CLineArray(2).Y = int_Y_ScaleValue 'the 60 set at frmload
    
    End Sub

    I can change these int_X_ScaleValue(s) according to a command button (e.g., cmd_ScaleValue80 where the int_ScaleValue resets to 80 from the initial 40), and this resets the CLineArray(2).X and Y to the values assigned. This then creates the necessary revised dummy /placeholder line of the correct x and y to override what was set in the mschart object properties at design time.

    This plots this dummy line above the y=0, and therefore it is off the chart. However, somehow, this fakes out the image that is clipboarded, and makes it print correctly. I bolded this because I think that this fake-out of some sort is the key to getting things to clipboard correctly, because the clipboard is picking up "more" than what you see on the screen at runtime as a displayed msChart, and it is the "more" that is also printed. It is as if what we see on the screen on simply a window to the overall chart and one must set this window dimension to over-ride what one sets in the properties page of teh MsChart itself.


    It appears to me that the clipboarded image is picking up the default msChart|Properties|Axis (x) or (Y) of min and max that one can set by right clicking the chart object. Regardless of what you set your x and y max and mins to in your code, the clipboarded image seems to refer back to what you input into that default menu- unless you create a fake line to define the window.

    All this written at 3am because it just would not let me sleep. I am pretty sure there is an elegant explanation of all this but this is what I have found, and what I "think" is going on. Of course, though, I am just like a monkey trying to paint a house.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width