From: Matt Gushee <matt@gushee.net>
To: caml-list@inria.fr
Subject: Re: [Caml-list] Polymorphic graph widget problem
Date: Fri, 29 Aug 2003 12:30:35 -0600 [thread overview]
Message-ID: <20030829183035.GF569@swordfish> (raw)
In-Reply-To: <20030829115446.GA879@redhat.com>
On Fri, Aug 29, 2003 at 12:54:46PM +0100, Richard Jones wrote:
>
> As part of a project I'm doing at the moment, I've written a Gtk graph
> widget using lablgtk. The graph currently plots ints, so the type
> looks something like this:
Hi, Richard--
I am working on a vaguely similar application. I say vaguely, because
the problem domain is very similar, but the practical constraints are
very different: my application also creates charts based on numeric (and
textual) data, but the input will usually be represented as strings (SQL
results and maybe XML data sets) and creates bitmap graphics for the
web. So my approach is necessarily quite different from yours, and I
don't know if any of my techniques will be useful to you. But just in
case it will help, let me briefly describe what I am doing.
* The two main active components in the system are the module types
CHART_TYPE and RENDERER, defined as follows:
module type CHART_TYPE =
sig
type t
val create : string list list -> t
val drawing : t -> cp_drawing
val raw_drawing : t -> cp_drawing (* W/O labels, axes, etc. -
useful for composite
charts *)
end
module type RENDERER =
sig
type t
val create : output_spec -> style -> t
val reset : t -> output_spec -> t
val render : cp_drawing -> unit
end
* All modules conforming to CHART_TYPE will produce an instance of
the 'cp_drawing' type, which is then passed to a RENDERER to
produce an actual image. The 'cp_drawing' type represents an
abstract drawing--by which I mean that it includes shapes such as
Rectangle, Ellipse, and so on, but all dimensions are expressed in
an abstract way, and graphical properties such as line width, fill,
etc. are unspecified (see example below).
* All numbers are handled internally as floats. Whether they are
*displayed* as floats or integers will be based on a style specified
by the user, who presumably knows which is most appropriate to the
data being charted.
EXAMPLE (this is an actual toplevel session, edited for clarity)
(* Create a chart, then a drawing based on it. *)
let data = [["A";"121.8"];["B";"84.3"];["C";"98"];["D";"108.5"]];;
let ch = SimpleColumnChart.create data;;
let dr = SimpleColumnChart.drawing ch;;
val dr : Chartpak.cp_drawing =
{drawing_id = "simple_column_chart"; components = <abstr>}
(* Here are the components--first the four columns *)
{id = "rect-0"; tags = []; label = SingleLabel "A";
figure = Rectangle (Slot 1, Start, AutoSizeCentered, Length 121.8)}
{id = "rect-1"; tags = []; label = SingleLabel "B";
figure = Rectangle (Slot 2, Start, AutoSizeCentered, Length 84.3)}
{id = "rect-2"; tags = []; label = SingleLabel "C";
figure = Rectangle (Slot 3, Start, AutoSizeCentered, Length 98.)}
{id = "rect-3"; tags = []; label = SingleLabel "D";
figure = Rectangle (Slot 4, Start, AutoSizeCentered, Length 108.5)}
(* And here are the vertical and horizontal axes. Note that the
length of the vertical axis is wrong -- it should be at least as
long as the longest column. Thanks for helping me discover this
bug! *)
{id = "line-0"; tags = []; label = FloatSeries (0., 100., 10.);
figure = Line (Start, Start, AutoSizeCentered, Length 100.)}
{id = "line-1"; tags = []; label = NoLabel;
figure = Line (Start, Start, SpanTo (Slot 4), AutoSizeCentered)}
--
Matt Gushee When a nation follows the Way,
Englewood, Colorado, USA Horses bear manure through
mgushee@havenrock.com its fields;
http://www.havenrock.com/ When a nation ignores the Way,
Horses bear soldiers through
its streets.
--Lao Tzu (Peter Merel, trans.)
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
prev parent reply other threads:[~2003-08-29 18:30 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-08-29 11:54 Richard Jones
2003-08-29 13:24 ` Remi Vanicat
2003-08-29 13:27 ` Michal Moskal
2003-08-29 13:40 ` Olivier Andrieu, Olivier Andrieu
2003-08-29 17:01 ` Issac Trotts
2003-08-29 18:30 ` Matt Gushee [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20030829183035.GF569@swordfish \
--to=matt@gushee.net \
--cc=caml-list@inria.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox