• Image create from barchart is always 400x400

    From Cecil Westerhof@21:1/5 to All on Sun Nov 12 13:43:11 2023
    I have the following code:
    wm title . "YouTube Weekly Views"
    blt::barchart .bc -plotbackground black
    .bc axis configure y -stepsize 100
    .bc element create best -xdata ${weekArr} -ydata ${viewsArr} -label {}
    pack .bc -side top -expand yes -fill both

    # Create a image to hold the graph, use the "snap" subcommand and then
    # write the image to a file.
    image create photo snapshot
    .bc snap snapshot
    snapshot write ${directory}${imageName} -format png
    # Display the barchart
    exec gwenview ${directory}${imageName} &
    # exit

    My views are going up and so are the weeks, but the generated image is
    always 400x400.
    The barchart itself is expanding, which I saw when putting the exit
    into comment.
    (At the moment I am only interested in the graphic file.)
    So why does snapshot not honour the dimensions of the barchart?

    --
    Cecil Westerhof
    Senior Software Engineer
    LinkedIn: http://www.linkedin.com/in/cecilwesterhof

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Scott Pitcher@21:1/5 to Cecil Westerhof on Wed Nov 15 08:58:03 2023
    On Sun, 12 Nov 2023 13:43:11 +0100
    Cecil Westerhof <Cecil@decebal.nl> wrote:

    I have the following code:
    wm title . "YouTube Weekly Views"
    blt::barchart .bc -plotbackground black
    .bc axis configure y -stepsize 100
    .bc element create best -xdata ${weekArr} -ydata
    ${viewsArr} -label {} pack .bc -side top -expand yes
    -fill both

    # Create a image to hold the graph, use the "snap" subcommand and
    then # write the image to a file.
    image create photo snapshot
    .bc snap snapshot
    snapshot write ${directory}${imageName} -format png
    # Display the barchart
    exec gwenview ${directory}${imageName} &
    # exit

    My views are going up and so are the weeks, but the generated image is
    always 400x400.
    The barchart itself is expanding, which I saw when putting the exit
    into comment.
    (At the moment I am only interested in the graphic file.)
    So why does snapshot not honour the dimensions of the barchart?


    Hi Cecil,

    To change the window size, add a -width and/or -height option to the
    barchart, such as:

    blt::barchart .bc -plotbackground black -width 1000 -height 300

    or:

    .bc configure -width 1000 -height 300

    You won't get a snapshot the correct size just yet, so before you
    say snap:

    update idletasks

    Then the window AND the snapshot image will be correct.

    So:
    .bc configure -width 1000 -height 300
    update idletasks
    image create photo snapshot
    .bc snap snapshot
    snapshot write ${directory}${imageName} -format png


    Kind regards,
    Scott



    --

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Cecil Westerhof@21:1/5 to Scott Pitcher on Wed Nov 15 11:24:50 2023
    Scott Pitcher <scotty@svptechnicalservices.com.au> writes:

    On Sun, 12 Nov 2023 13:43:11 +0100
    Cecil Westerhof <Cecil@decebal.nl> wrote:

    I have the following code:
    wm title . "YouTube Weekly Views"
    blt::barchart .bc -plotbackground black
    .bc axis configure y -stepsize 100
    .bc element create best -xdata ${weekArr} -ydata
    ${viewsArr} -label {} pack .bc -side top -expand yes
    -fill both

    # Create a image to hold the graph, use the "snap" subcommand and
    then # write the image to a file.
    image create photo snapshot
    .bc snap snapshot
    snapshot write ${directory}${imageName} -format png
    # Display the barchart
    exec gwenview ${directory}${imageName} &
    # exit

    My views are going up and so are the weeks, but the generated image is
    always 400x400.
    The barchart itself is expanding, which I saw when putting the exit
    into comment.
    (At the moment I am only interested in the graphic file.)
    So why does snapshot not honour the dimensions of the barchart?


    To change the window size, add a -width and/or -height option to the barchart, such as:

    blt::barchart .bc -plotbackground black -width 1000 -height 300

    or:

    .bc configure -width 1000 -height 300

    That is not really necessary, because the window itself has a good
    size. (For no at least.)


    You won't get a snapshot the correct size just yet, so before you
    say snap:

    update idletasks

    That is what I needed. :-D

    I now have:
    pack .bc -side top -expand yes -fill both

    # Create a image to hold the graph, use the "snap" subcommand and then
    # write the image to a file.
    # Make sure the snapshot has the right size
    update idletasks
    image create photo snapshot
    .bc snap snapshot
    snapshot write ${directory}${imageName} -format png

    Thank you very much,

    --
    Cecil Westerhof
    Senior Software Engineer
    LinkedIn: http://www.linkedin.com/in/cecilwesterhof

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)