Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

To err is human -- to blame it on a computer is even more so.


devel / comp.lang.tcl / Writing bar chart to file

SubjectAuthor
* Writing bar chart to fileCecil Westerhof
+- Writing bar chart to fileRobert Heller
+* Writing bar chart to filegreg
|`* Writing bar chart to fileCecil Westerhof
| +- Writing bar chart to filegreg
| +- Writing bar chart to fileRobert Heller
| `- Writing bar chart to fileCecil Westerhof
`* Writing bar chart to fileScott Pitcher
 `* Writing bar chart to fileCecil Westerhof
  `- Writing bar chart to fileCecil Westerhof

1
Writing bar chart to file

<87wmvgi2el.fsf@munus.decebal.nl>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=12280&group=comp.lang.tcl#12280

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Cec...@decebal.nl (Cecil Westerhof)
Newsgroups: comp.lang.tcl
Subject: Writing bar chart to file
Date: Sat, 21 Oct 2023 14:30:10 +0200
Organization: Decebal Computing
Lines: 46
Message-ID: <87wmvgi2el.fsf@munus.decebal.nl>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="2ad98b196fca901059ccc46d0ee27bed";
logging-data="1860493"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18308yDUGgfBTv57QtaYBTmv33rhMIlrUU="
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux)
Cancel-Lock: sha1:thkiaP3WY2EDO+e9TeSL6CLITm8=
sha1:wR8GuWQfMehNOfLSrOB1dl2c7ak=
 by: Cecil Westerhof - Sat, 21 Oct 2023 12:30 UTC

Three years ago I played a bit with bar charts.
I started a YouTube channel and I like to create some bar charts.
An example is:
#!/usr/bin/env tclsh

package require Tk
package require BLT

package require sqlite3

set viewsArr {}
set weekArr {}

sqlite3 db ~/Databases/youtube.sqlite
db eval {
SELECT strftime('%W', dayDate, '+1 day') AS WeekNo
, SUM(dayViews) AS WeekTotals
FROM dayViews
WHERE WeekNo > '37'
GROUP BY WeekNo
ORDER BY WeekNo
} {
lappend viewsArr ${WeekTotals}
lappend weekArr ${WeekNo}
}
db close

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

This gives a window with the bar chart. I can make a screen dump
of-course, but is there a way to also write the bar chart to a PNG
file?

What is a good resource for learning to work with Tk, (bar) charts and
the like?

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

Re: Writing bar chart to file

<rXidnVge3vjdaK74nZ2dnZfqn_idnZ2d@giganews.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=12282&group=comp.lang.tcl#12282

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!rocksolid2!news.neodome.net!weretis.net!feeder8.news.weretis.net!3.eu.feeder.erje.net!1.us.feeder.erje.net!feeder.erje.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!feeder.usenetexpress.com!tr1.iad1.usenetexpress.com!69.80.99.27.MISMATCH!Xl.tags.giganews.com!local-2.nntp.ord.giganews.com!news.giganews.com.POSTED!not-for-mail
NNTP-Posting-Date: Sat, 21 Oct 2023 15:58:56 +0000
MIME-Version: 1.0
From: hel...@deepsoft.com (Robert Heller)
Organization: Deepwoods Software
X-Newsreader: TkNews 3.0 (1.2.15)
Subject: Re: Writing bar chart to file
In-Reply-To: <87wmvgi2el.fsf@munus.decebal.nl>
References: <87wmvgi2el.fsf@munus.decebal.nl>
Newsgroups: comp.lang.tcl
Content-Type: text/plain; charset="us-ascii"
Originator: heller@sharky4.deepsoft.com
Message-ID: <rXidnVge3vjdaK74nZ2dnZfqn_idnZ2d@giganews.com>
Date: Sat, 21 Oct 2023 15:58:56 +0000
Lines: 65
X-Usenet-Provider: http://www.giganews.com
X-Trace: sv3-ouCIQK+pL3+Ay2mG5cd9dZkc7AOhQyCC42aifA8Lg69T1BggGexSIE/hCxVnrNh/xl+2vsvpNHJZpjo!LKxceTCzoMIGchQn3lyqca/cYXvsScavdTtE7ukUtedd2vrexcfRkq4NR5io+asJ8wberhHzDdUa!RJo=
X-Complaints-To: abuse@giganews.com
X-DMCA-Notifications: http://www.giganews.com/info/dmca.html
X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers
X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly
X-Postfilter: 1.3.40
 by: Robert Heller - Sat, 21 Oct 2023 15:58 UTC

Look for pdf4tcl: https://sourceforge.net/projects/pdf4tcl/

You can either recode the drawing code to create a PDF bargraph, or just
convert the canvas to PDF.

Note: natively, Tcl can export a canvas to a PostScript file ($canvas
postscript ...). There are utilities to convert PostScript to PDF or PNG
(GhostScript can do that).

And I believe the TkImg package can convert a canvas to an image, which could
then be saved as a PNG file.

At Sat, 21 Oct 2023 14:30:10 +0200 Cecil Westerhof <Cecil@decebal.nl> wrote:

>
> Three years ago I played a bit with bar charts.
> I started a YouTube channel and I like to create some bar charts.
> An example is:
> #!/usr/bin/env tclsh
>
>
> package require Tk
> package require BLT
>
> package require sqlite3
>
>
> set viewsArr {}
> set weekArr {}
>
> sqlite3 db ~/Databases/youtube.sqlite
> db eval {
> SELECT strftime('%W', dayDate, '+1 day') AS WeekNo
> , SUM(dayViews) AS WeekTotals
> FROM dayViews
> WHERE WeekNo > '37'
> GROUP BY WeekNo
> ORDER BY WeekNo
> } {
> lappend viewsArr ${WeekTotals}
> lappend weekArr ${WeekNo}
> }
> db close
>
> 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
>
> This gives a window with the bar chart. I can make a screen dump
> of-course, but is there a way to also write the bar chart to a PNG
> file?
>
>
> What is a good resource for learning to work with Tk, (bar) charts and
> the like?
>

--
Robert Heller -- Cell: 413-658-7953 GV: 978-633-5364
Deepwoods Software -- Custom Software Services
http://www.deepsoft.com/ -- Linux Administration Services
heller@deepsoft.com -- Webhosting Services

Re: Writing bar chart to file

<40c27c86-528a-42e5-b2b6-8e9820c20ab4n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=12284&group=comp.lang.tcl#12284

  copy link   Newsgroups: comp.lang.tcl
X-Received: by 2002:a05:620a:8e10:b0:774:143e:f9a1 with SMTP id re16-20020a05620a8e1000b00774143ef9a1mr80837qkn.11.1697909347379;
Sat, 21 Oct 2023 10:29:07 -0700 (PDT)
X-Received: by 2002:a05:6808:28d:b0:3ae:1b49:c4d6 with SMTP id
z13-20020a056808028d00b003ae1b49c4d6mr1707745oic.10.1697909347018; Sat, 21
Oct 2023 10:29:07 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.tcl
Date: Sat, 21 Oct 2023 10:29:06 -0700 (PDT)
In-Reply-To: <87wmvgi2el.fsf@munus.decebal.nl>
Injection-Info: google-groups.googlegroups.com; posting-host=185.250.212.52; posting-account=99ziWAoAAADLScDbI_CyfIcpa_gFZ0zh
NNTP-Posting-Host: 185.250.212.52
References: <87wmvgi2el.fsf@munus.decebal.nl>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <40c27c86-528a-42e5-b2b6-8e9820c20ab4n@googlegroups.com>
Subject: Re: Writing bar chart to file
From: gregor.e...@googlemail.com (greg)
Injection-Date: Sat, 21 Oct 2023 17:29:07 +0000
Content-Type: text/plain; charset="UTF-8"
 by: greg - Sat, 21 Oct 2023 17:29 UTC

Cecil Westerhof schrieb am Samstag, 21. Oktober 2023 um 14:44:10 UTC+2:
> Three years ago I played a bit with bar charts.
> I started a YouTube channel and I like to create some bar charts.
> An example is:
> #!/usr/bin/env tclsh
>
>
> package require Tk
> package require BLT
>
> package require sqlite3
>
>
> set viewsArr {}
> set weekArr {}
>
> sqlite3 db ~/Databases/youtube.sqlite
> db eval {
> SELECT strftime('%W', dayDate, '+1 day') AS WeekNo
> , SUM(dayViews) AS WeekTotals
> FROM dayViews
> WHERE WeekNo > '37'
> GROUP BY WeekNo
> ORDER BY WeekNo
> } {
> lappend viewsArr ${WeekTotals}
> lappend weekArr ${WeekNo}
> }
> db close
>
> 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
>
> This gives a window with the bar chart. I can make a screen dump
> of-course, but is there a way to also write the bar chart to a PNG
> file?
>
>
> What is a good resource for learning to work with Tk, (bar) charts and
> the like?
>
> --
> Cecil Westerhof
> Senior Software Engineer
> LinkedIn: http://www.linkedin.com/in/cecilwesterhof

slides.pdf
https://blt.sourceforge.net/

https://wiki.tcl-lang.org/page/BLT+%2D+graph+%2D+printing+postscript

and
https://wiki.tcl-lang.org/page/BLT

debian 12 with blt and blt-demo

Re: Writing bar chart to file

<87o7grivc1.fsf@munus.decebal.nl>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=12286&group=comp.lang.tcl#12286

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Cec...@decebal.nl (Cecil Westerhof)
Newsgroups: comp.lang.tcl
Subject: Re: Writing bar chart to file
Date: Sat, 21 Oct 2023 22:17:34 +0200
Organization: Decebal Computing
Lines: 70
Message-ID: <87o7grivc1.fsf@munus.decebal.nl>
References: <87wmvgi2el.fsf@munus.decebal.nl>
<40c27c86-528a-42e5-b2b6-8e9820c20ab4n@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="2ad98b196fca901059ccc46d0ee27bed";
logging-data="2062268"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/TrWcyRieXk/89tww9ZpJ4ZysTK9KNDEU="
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux)
Cancel-Lock: sha1:q7/cOgxDZHXFmxvni1wsQ2Ywkjs=
sha1:SE56akoDyDcS6rs7mSLOBfTx1ZY=
 by: Cecil Westerhof - Sat, 21 Oct 2023 20:17 UTC

greg <gregor.ebbing@googlemail.com> writes:

> Cecil Westerhof schrieb am Samstag, 21. Oktober 2023 um 14:44:10 UTC+2:
>> Three years ago I played a bit with bar charts.
>> I started a YouTube channel and I like to create some bar charts.
>> An example is:
>> #!/usr/bin/env tclsh
>>
>>
>> package require Tk
>> package require BLT
>>
>> package require sqlite3
>>
>>
>> set viewsArr {}
>> set weekArr {}
>>
>> sqlite3 db ~/Databases/youtube.sqlite
>> db eval {
>> SELECT strftime('%W', dayDate, '+1 day') AS WeekNo
>> , SUM(dayViews) AS WeekTotals
>> FROM dayViews
>> WHERE WeekNo > '37'
>> GROUP BY WeekNo
>> ORDER BY WeekNo
>> } {
>> lappend viewsArr ${WeekTotals}
>> lappend weekArr ${WeekNo}
>> }
>> db close
>>
>> 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
>>
>> This gives a window with the bar chart. I can make a screen dump
>> of-course, but is there a way to also write the bar chart to a PNG
>> file?
>>
>>
>> What is a good resource for learning to work with Tk, (bar) charts and
>> the like?
>
>
>
> slides.pdf
> https://blt.sourceforge.net/
>
> https://wiki.tcl-lang.org/page/BLT+%2D+graph+%2D+printing+postscript" rel="nofollow" target="_blank">https://wiki.tcl-lang.org/page/BLT+%2D+graph+%2D+printing+postscript
>
> and
> https://wiki.tcl-lang.org/page/BLT

At the moment I use:
.bc postscript configure -landscape yes -maxpect yes
.bc postscript output ytWeek.ps

And I convert it to png with:
gs -dSAFER -o ytWeek.png ytWeek.ps

Works reasonable, but there is a problem: left and right there is a
transparency area of 135 pixels and above and under of 95 pixels.
How do I get rid of this area?

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

Re: Writing bar chart to file

<31d03adc-30f6-414b-9b3d-22f82855c541n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=12287&group=comp.lang.tcl#12287

  copy link   Newsgroups: comp.lang.tcl
X-Received: by 2002:a05:620a:45a9:b0:774:18c5:88a2 with SMTP id bp41-20020a05620a45a900b0077418c588a2mr114946qkb.11.1697922852360;
Sat, 21 Oct 2023 14:14:12 -0700 (PDT)
X-Received: by 2002:a9d:6a4a:0:b0:6b9:2c07:8849 with SMTP id
h10-20020a9d6a4a000000b006b92c078849mr1695221otn.0.1697922852017; Sat, 21 Oct
2023 14:14:12 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!feeder1.feed.usenet.farm!feed.usenet.farm!peer03.ams4!peer.am4.highwinds-media.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.tcl
Date: Sat, 21 Oct 2023 14:14:11 -0700 (PDT)
In-Reply-To: <87o7grivc1.fsf@munus.decebal.nl>
Injection-Info: google-groups.googlegroups.com; posting-host=185.250.212.52; posting-account=99ziWAoAAADLScDbI_CyfIcpa_gFZ0zh
NNTP-Posting-Host: 185.250.212.52
References: <87wmvgi2el.fsf@munus.decebal.nl> <40c27c86-528a-42e5-b2b6-8e9820c20ab4n@googlegroups.com>
<87o7grivc1.fsf@munus.decebal.nl>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <31d03adc-30f6-414b-9b3d-22f82855c541n@googlegroups.com>
Subject: Re: Writing bar chart to file
From: gregor.e...@googlemail.com (greg)
Injection-Date: Sat, 21 Oct 2023 21:14:12 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 4097
 by: greg - Sat, 21 Oct 2023 21:14 UTC

Cecil Westerhof schrieb am Samstag, 21. Oktober 2023 um 22:28:25 UTC+2:
> greg writes:
>
> > Cecil Westerhof schrieb am Samstag, 21. Oktober 2023 um 14:44:10 UTC+2:
> >> Three years ago I played a bit with bar charts.
> >> I started a YouTube channel and I like to create some bar charts.
> >> An example is:
> >> #!/usr/bin/env tclsh
> >>
> >>
> >> package require Tk
> >> package require BLT
> >>
> >> package require sqlite3
> >>
> >>
> >> set viewsArr {}
> >> set weekArr {}
> >>
> >> sqlite3 db ~/Databases/youtube.sqlite
> >> db eval {
> >> SELECT strftime('%W', dayDate, '+1 day') AS WeekNo
> >> , SUM(dayViews) AS WeekTotals
> >> FROM dayViews
> >> WHERE WeekNo > '37'
> >> GROUP BY WeekNo
> >> ORDER BY WeekNo
> >> } {
> >> lappend viewsArr ${WeekTotals}
> >> lappend weekArr ${WeekNo}
> >> }
> >> db close
> >>
> >> 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
> >>
> >> This gives a window with the bar chart. I can make a screen dump
> >> of-course, but is there a way to also write the bar chart to a PNG
> >> file?
> >>
> >>
> >> What is a good resource for learning to work with Tk, (bar) charts and
> >> the like?
> >
> >
> >
> > slides.pdf
> > https://blt.sourceforge.net/
> >
> > https://wiki.tcl-lang.org/page/BLT+%2D+graph+%2D+printing+postscript" rel="nofollow" target="_blank">https://wiki.tcl-lang.org/page/BLT+%2D+graph+%2D+printing+postscript
> >
> > and
> > https://wiki.tcl-lang.org/page/BLT
> At the moment I use:
> .bc postscript configure -landscape yes -maxpect yes
> .bc postscript output ytWeek.ps
>
> And I convert it to png with:
> gs -dSAFER -o ytWeek.png ytWeek.ps
>
> Works reasonable, but there is a problem: left and right there is a
> transparency area of 135 pixels and above and under of 95 pixels.
> How do I get rid of this area?
> --
> Cecil Westerhof
> Senior Software Engineer
> LinkedIn: http://www.linkedin.com/in/cecilwesterhof

https://manpages.debian.org/testing/blt-dev/blt::graph.3tcl.en.html

Finally, to get hardcopy of the graph, use the postscript component.
# Print the graph into file "file.ps"

..g postscript output file.ps -maxpect yes -decorations no

This generates a file file.ps containing the encapsulated PostScript of the graph. The option -maxpect says to scale the plot to the size of the page. Turning off the -decorations option denotes that no borders or color backgrounds should be drawn (i.e. the background of the margins, legend, and plotting area will be white).

Re: Writing bar chart to file

<m7WdnQLKkYS43Kn4nZ2dnZfqnPudnZ2d@giganews.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=12289&group=comp.lang.tcl#12289

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!rocksolid2!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer01.iad!feed-me.highwinds-media.com!news.highwinds-media.com!Xl.tags.giganews.com!local-1.nntp.ord.giganews.com!news.giganews.com.POSTED!not-for-mail
NNTP-Posting-Date: Sat, 21 Oct 2023 21:22:45 +0000
MIME-Version: 1.0
From: hel...@deepsoft.com (Robert Heller)
Organization: Deepwoods Software
X-Newsreader: TkNews 3.0 (1.2.15)
Subject: Re: Writing bar chart to file
In-Reply-To: <87o7grivc1.fsf@munus.decebal.nl>
References: <87wmvgi2el.fsf@munus.decebal.nl>??<40c27c86-528a-42e5-b2b6-8e9820c20ab4n@googlegroups.com>
<87o7grivc1.fsf@munus.decebal.nl>
Newsgroups: comp.lang.tcl
Content-Type: text/plain;
charset="us-ascii"
Originator: heller@sharky4.deepsoft.com
Message-ID: <m7WdnQLKkYS43Kn4nZ2dnZfqnPudnZ2d@giganews.com>
Date: Sat, 21 Oct 2023 21:22:45 +0000
Lines: 84
X-Usenet-Provider: http://www.giganews.com
X-Trace: sv3-eQp0CuWx6x66V516Jr5IIWv0qZ7BjJi3B0m1NJONngJwOmWOLDVq9zHZyRms66QB/T/a+tnkT7cTxBg!oBPgaZCO5zVd/M8uiE0H0qbWkAtiAgkGkxcACA3UstqROQl/mp0p/kIFfmDD8zmrDjKraRNLqzgo!A18=
X-Complaints-To: abuse@giganews.com
X-DMCA-Notifications: http://www.giganews.com/info/dmca.html
X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers
X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly
X-Postfilter: 1.3.40
X-Received-Bytes: 3857
 by: Robert Heller - Sat, 21 Oct 2023 21:22 UTC

At Sat, 21 Oct 2023 22:17:34 +0200 Cecil Westerhof <Cecil@decebal.nl> wrote:

>
> greg <gregor.ebbing@googlemail.com> writes:
>
> > Cecil Westerhof schrieb am Samstag, 21. Oktober 2023 um 14:44:10 UTC+2:
> >> Three years ago I played a bit with bar charts.
> >> I started a YouTube channel and I like to create some bar charts.
> >> An example is:
> >> #!/usr/bin/env tclsh
> >>
> >>
> >> package require Tk
> >> package require BLT
> >>
> >> package require sqlite3
> >>
> >>
> >> set viewsArr {}
> >> set weekArr {}
> >>
> >> sqlite3 db ~/Databases/youtube.sqlite
> >> db eval {
> >> SELECT strftime('%W', dayDate, '+1 day') AS WeekNo
> >> , SUM(dayViews) AS WeekTotals
> >> FROM dayViews
> >> WHERE WeekNo > '37'
> >> GROUP BY WeekNo
> >> ORDER BY WeekNo
> >> } {
> >> lappend viewsArr ${WeekTotals}
> >> lappend weekArr ${WeekNo}
> >> }
> >> db close
> >>
> >> 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
> >>
> >> This gives a window with the bar chart. I can make a screen dump
> >> of-course, but is there a way to also write the bar chart to a PNG
> >> file?
> >>
> >>
> >> What is a good resource for learning to work with Tk, (bar) charts and
> >> the like?
> >
> >
> >
> > slides.pdf
> > https://blt.sourceforge.net/
> >
> > https://wiki.tcl-lang.org/page/BLT+%2D+graph+%2D+printing+postscript" rel="nofollow" target="_blank">https://wiki.tcl-lang.org/page/BLT+%2D+graph+%2D+printing+postscript
> >
> > and
> > https://wiki.tcl-lang.org/page/BLT
>
> At the moment I use:
> .bc postscript configure -landscape yes -maxpect yes
> .bc postscript output ytWeek.ps
>
> And I convert it to png with:
> gs -dSAFER -o ytWeek.png ytWeek.ps
>
> Works reasonable, but there is a problem: left and right there is a
> transparency area of 135 pixels and above and under of 95 pixels.
> How do I get rid of this area?

GhostScript is probably creating a "page" (eg 8.5" x 11") and is filling out
the "empty" "paper". You probably need to set the paper size to match the
image (or something like that). I wonder if ImageMagick will take care of
that...

sudo apt install imagemagick

>

--
Robert Heller -- Cell: 413-658-7953 GV: 978-633-5364
Deepwoods Software -- Custom Software Services
http://www.deepsoft.com/ -- Linux Administration Services
heller@deepsoft.com -- Webhosting Services

Re: Writing bar chart to file

<87h6mjines.fsf@munus.decebal.nl>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=12291&group=comp.lang.tcl#12291

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Cec...@decebal.nl (Cecil Westerhof)
Newsgroups: comp.lang.tcl
Subject: Re: Writing bar chart to file
Date: Sun, 22 Oct 2023 01:08:43 +0200
Organization: Decebal Computing
Lines: 75
Message-ID: <87h6mjines.fsf@munus.decebal.nl>
References: <87wmvgi2el.fsf@munus.decebal.nl>
<40c27c86-528a-42e5-b2b6-8e9820c20ab4n@googlegroups.com>
<87o7grivc1.fsf@munus.decebal.nl>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="80c8815b1f10f3c7644067cb404013dd";
logging-data="2133372"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+SOceaoSVt4rVNMFKRIePDk912dyDfsDA="
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux)
Cancel-Lock: sha1:bwLZzKOp/N7BZZDk9TMJzqKEi4I=
sha1:80w1Fifn2InWKtVrohwiwVLy8fk=
 by: Cecil Westerhof - Sat, 21 Oct 2023 23:08 UTC

Cecil Westerhof <Cecil@decebal.nl> writes:

> greg <gregor.ebbing@googlemail.com> writes:
>
>> Cecil Westerhof schrieb am Samstag, 21. Oktober 2023 um 14:44:10 UTC+2:
>>> Three years ago I played a bit with bar charts.
>>> I started a YouTube channel and I like to create some bar charts.
>>> An example is:
>>> #!/usr/bin/env tclsh
>>>
>>>
>>> package require Tk
>>> package require BLT
>>>
>>> package require sqlite3
>>>
>>>
>>> set viewsArr {}
>>> set weekArr {}
>>>
>>> sqlite3 db ~/Databases/youtube.sqlite
>>> db eval {
>>> SELECT strftime('%W', dayDate, '+1 day') AS WeekNo
>>> , SUM(dayViews) AS WeekTotals
>>> FROM dayViews
>>> WHERE WeekNo > '37'
>>> GROUP BY WeekNo
>>> ORDER BY WeekNo
>>> } {
>>> lappend viewsArr ${WeekTotals}
>>> lappend weekArr ${WeekNo}
>>> }
>>> db close
>>>
>>> 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
>>>
>>> This gives a window with the bar chart. I can make a screen dump
>>> of-course, but is there a way to also write the bar chart to a PNG
>>> file?
>>>
>>>
>>> What is a good resource for learning to work with Tk, (bar) charts and
>>> the like?
>>
>>
>>
>> slides.pdf
>> https://blt.sourceforge.net/
>>
>> https://wiki.tcl-lang.org/page/BLT+%2D+graph+%2D+printing+postscript" rel="nofollow" target="_blank">https://wiki.tcl-lang.org/page/BLT+%2D+graph+%2D+printing+postscript
>>
>> and
>> https://wiki.tcl-lang.org/page/BLT
>
> At the moment I use:
> .bc postscript configure -landscape yes -maxpect yes
> .bc postscript output ytWeek.ps
>
> And I convert it to png with:
> gs -dSAFER -o ytWeek.png ytWeek.ps
>
> Works reasonable, but there is a problem: left and right there is a
> transparency area of 135 pixels and above and under of 95 pixels.
> How do I get rid of this area?

By using convert from Image Magick:
convert -trim -resize 800x ytWeek.ps ytWeek.png

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

Re: Writing bar chart to file

<20231022121409.3361f32a@officepc.svpts>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=12292&group=comp.lang.tcl#12292

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: sco...@svptechnicalservices.com.au (Scott Pitcher)
Newsgroups: comp.lang.tcl
Subject: Re: Writing bar chart to file
Date: Sun, 22 Oct 2023 12:17:08 +1100
Organization: SVP TECHNICAL SERVICES
Lines: 90
Message-ID: <20231022121409.3361f32a@officepc.svpts>
References: <87wmvgi2el.fsf@munus.decebal.nl>
MIME-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Injection-Info: dont-email.me; posting-host="977b87e1bd2d46c5f41f2ad40e45a92e";
logging-data="2126587"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19NgdY4zmsAcVlt/bcgKpLkUXO9HhNTFbE="
Cancel-Lock: sha1:wzFU7+Zbai1UTZqBDZnVtF/HpKY=
X-Newsreader: Claws Mail 3.16.0 (GTK+ 2.24.32; x86_64-pc-linux-gnu)
 by: Scott Pitcher - Sun, 22 Oct 2023 01:17 UTC

On Sat, 21 Oct 2023 14:30:10 +0200
Cecil Westerhof <Cecil@decebal.nl> wrote:

> Three years ago I played a bit with bar charts.
> I started a YouTube channel and I like to create some bar charts.
> An example is:
> #!/usr/bin/env tclsh
>
>
> package require Tk
> package require BLT
>
> package require sqlite3
>
>
> set viewsArr {}
> set weekArr {}
>
> sqlite3 db ~/Databases/youtube.sqlite
> db eval {
> SELECT strftime('%W', dayDate, '+1 day') AS WeekNo
> , SUM(dayViews) AS WeekTotals
> FROM dayViews
> WHERE WeekNo > '37'
> GROUP BY WeekNo
> ORDER BY WeekNo
> } {
> lappend viewsArr ${WeekTotals}
> lappend weekArr ${WeekNo}
> }
> db close
>
> 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
>
> This gives a window with the bar chart. I can make a screen dump
> of-course, but is there a way to also write the bar chart to a PNG
> file?
>

Yes. I tested this on Ubuntu 18 with package tk8.6-blt2.5, which gives
BLT version 2.5.3.

# 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 snapshot.png -format png

>
> What is a good resource for learning to work with Tk, (bar) charts and
> the like?
>

Tcl.

I didn't have your database as a data set, so the expr function can
quickly generate data sets based upon any function you can imagine -

# Sample graph data generator.
proc grfunc {x} {
set xr [expr $x * 3.14159 / 180]
return [expr sin($xr) + 4 * cos($xr)]
}

set xseries ""
set yseries ""
set xstep 5

for {set x 0} {$x < 360} {incr x $xstep} {
lappend xseries $x
lappend yseries [grfunc $x]
}

blt::barchart .bc -plotbackground black
..bc axis configure y -stepsize 100
..bc element create best -xdata $xseries -ydata $yseries \
-label {} -barwidth $xstep
pack .bc -side top -expand yes -fill both

Kind regards,
Scott

--

Re: Writing bar chart to file

<87cyx6iwd9.fsf@munus.decebal.nl>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=12295&group=comp.lang.tcl#12295

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Cec...@decebal.nl (Cecil Westerhof)
Newsgroups: comp.lang.tcl
Subject: Re: Writing bar chart to file
Date: Sun, 22 Oct 2023 16:07:30 +0200
Organization: Decebal Computing
Lines: 62
Message-ID: <87cyx6iwd9.fsf@munus.decebal.nl>
References: <87wmvgi2el.fsf@munus.decebal.nl>
<20231022121409.3361f32a@officepc.svpts>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="80c8815b1f10f3c7644067cb404013dd";
logging-data="2604665"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18iQ1jNDW4MhLpCSnu+WK1HnQjMCsucqhc="
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux)
Cancel-Lock: sha1:nT9+JJmXc4Ws4AmJXtHJZemp5yE=
sha1:nMqTTGN7byNlA3r8P0mIMAWWKrE=
 by: Cecil Westerhof - Sun, 22 Oct 2023 14:07 UTC

Scott Pitcher <scotty@svptechnicalservices.com.au> writes:

> On Sat, 21 Oct 2023 14:30:10 +0200
> Cecil Westerhof <Cecil@decebal.nl> wrote:
>
>> Three years ago I played a bit with bar charts.
>> I started a YouTube channel and I like to create some bar charts.
>> An example is:
>> #!/usr/bin/env tclsh
>>
>>
>> package require Tk
>> package require BLT
>>
>> package require sqlite3
>>
>>
>> set viewsArr {}
>> set weekArr {}
>>
>> sqlite3 db ~/Databases/youtube.sqlite
>> db eval {
>> SELECT strftime('%W', dayDate, '+1 day') AS WeekNo
>> , SUM(dayViews) AS WeekTotals
>> FROM dayViews
>> WHERE WeekNo > '37'
>> GROUP BY WeekNo
>> ORDER BY WeekNo
>> } {
>> lappend viewsArr ${WeekTotals}
>> lappend weekArr ${WeekNo}
>> }
>> db close
>>
>> 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
>>
>> This gives a window with the bar chart. I can make a screen dump
>> of-course, but is there a way to also write the bar chart to a PNG
>> file?
>>
>
> Yes. I tested this on Ubuntu 18 with package tk8.6-blt2.5, which gives
> BLT version 2.5.3.
>
> # 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 snapshot.png -format png

Works likes a charm.
Thanks.

Now I have to learn to get the most out of it. ;-)

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

Re: Writing bar chart to file

<87zg0ah9an.fsf@munus.decebal.nl>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=12298&group=comp.lang.tcl#12298

  copy link   Newsgroups: comp.lang.tcl
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Cec...@decebal.nl (Cecil Westerhof)
Newsgroups: comp.lang.tcl
Subject: Re: Writing bar chart to file
Date: Sun, 22 Oct 2023 19:11:12 +0200
Organization: Decebal Computing
Lines: 25
Message-ID: <87zg0ah9an.fsf@munus.decebal.nl>
References: <87wmvgi2el.fsf@munus.decebal.nl>
<20231022121409.3361f32a@officepc.svpts> <87cyx6iwd9.fsf@munus.decebal.nl>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="80c8815b1f10f3c7644067cb404013dd";
logging-data="2697584"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19atWfGYZTo4WlJhvh48guZoQiCZDOnmLw="
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux)
Cancel-Lock: sha1:Tsfe4oBzMF96isutj+lpmVKAk3g=
sha1:TvkRNio7ISa7cLgSEgIu1KSpwbc=
 by: Cecil Westerhof - Sun, 22 Oct 2023 17:11 UTC

Cecil Westerhof <Cecil@decebal.nl> writes:

>> Yes. I tested this on Ubuntu 18 with package tk8.6-blt2.5, which gives
>> BLT version 2.5.3.
>>
>> # 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 snapshot.png -format png
>
> Works likes a charm.
> Thanks.
>
> Now I have to learn to get the most out of it. ;-)

By the way the generated PNG is a lot smaller as the one generated
with the postscript/ghostscript way and at the same time looks a lot
better.
It is also less steps, so a very BIG win.

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

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor