Simple bar graph ideas

I’m interfacing with Blood Analyzers in my veterinary emergency hospital via a serial connection.

I need to draw a simple bar graph given 3 pieces of data. I have a description, a value, and a range. I’m contemplating just using a Canvas, but thought I’d throw this out there in case there is a better method. I’m trying to duplicate the view shown in the attached image. I’ve highlighted one line in blue. In this example I’d have data sent via serial to me like this

ALB         3.1      2.5-4.4        g/dL

I parse the data and get the description as “ALB” (Alanine transaminase ) the value as “3.1” (I append the ‘g/dL’ to this) and then the range is “2.5 to 4.4”. From this, if it is out of range I just plot a red bar (to the left if it is low or to the right if it is high), if it is in range I plot where it falls within the range instead. There will be multiple results, and the quantity of results will vary depending on what main test is being run on the analyzer. I just keep parsing the received data and adding another set of values and graph below the previous one. I’ll need to be able to print and also export the whole page of results to a JPG to be sent to our Practice Management software.

Any smart folks have a better way of doing this than drawing each graph in a canvas

full sample of results received via the serial port from one type of test we run. In this instance I’d have 10 small graphs to plot under each other:

[code] VetScan VS2
Kidney Profile Plus
07 Jan 2019 02:38 AM
Sample Type: Dog
Patient ID: 25008
Rotor Lot Number: 8141BB3
Serial Number: 0000Vxxxxx

GLU 93 60-110 mg/dL
BUN 17 7-25 mg/dL
CA 11.3 8.6-11.8 mg/dL
CRE 1.1 0.3-1.4 mg/dL
ALB 3.2 2.5-4.4 g/dL
PHOS 5.5 2.9-6.6 mg/dL
NA+ 129 * 138-160 mmol/L
K+ 7.1 * 3.7-5.8 mmol/L
CL- 105 95-119 mmol/L
tCO2 21 12-27 mmol/L

HEM 1+ LIP 0 ICT 0 [/code]
Values with a “*” warn me the value is out of range, just in case anyone wondered why some values had this.

I know its an addon and therefore additional cost, but i could not help but see by the similarity between the picture of the results and the piDog dataview and listbox. It would certainly make printing and export quite easy.

I would use a custom listbox, drawing the graphs with cellbackgroundpaint event.
then printing and exporting is a listbox method.

Thank you for the link Paul. I don’t mind using plugins when needed. piDog looks to be very comprehensive, and I’m worried it may take as long to figure out the little piece I need from this as to write the code myself :wink:
I’ve bookmarked it in case this is the only suggestion.

Just use a listbox and do the drawing in the CellBackgroundPaint event of the fourth column

I had not even considered using a ListBox!

What Jean-Yves said (overlapping postings)

Data in columns are usually a pretty good hint :wink:

Hopefully this taxes your brains more than my original question :wink:

I presume you are saying I’ll need to create my own method to print/export as it doesn’t appear to be an existing method. Has anyone already done this and have a code snippet to share?

You could also use a series of progressbars.

this is a good exercice, you can do it crude way, only for your usage. or full extended and it becomes a commercial plugin …
I took time to do it, the way I want, it’s not trivial, and you loose time if you want to perfect it to the pixel.
if you don’t want to build it, then buy something like pidog it’s in.
I mainly do things like that by myself, even if it takes time, because you learn a lot from it, and because generally in other’s code, there is always something that you don’t want and even if you have the source code, it’s not meant to behave like you really want.

I just found these examples. Hopefully they will help others working with ListBox

sbListbox Printer will print a listbox
Magic Listbox expands on the Xojo ListBox