Hi Raul, thank you very much for your hints - I really could not expect so much effort from you to work on my problem! I've been pretty busy during the last days and did not find the time to study your code in detail. But I'll see, what I can make out of it during the next days.
Kind regards, Thomas Am Fr., 19. Nov. 2021 um 23:08 Uhr schrieb Raul Miller <[email protected]>: > > So... I was fiddling around with this and I ran into enough obstacles > that I figured I should just show some code rather than expect anyone > else to have done this. > > T =: 3 3 $ 'Task 1';1;3;'Task 2';3;6;'Task 3';4;7 > > require'gl2' > coinsert'jgl2' > > glqtextmetrics=: {{ > tm=. 7#2-2 > chkgl2 cdrc=. ('"',libjqt,'" glqtextmetrics ',(IFWIN#'+'),' i *i') cd <tm > 1{::cdrc > }}"1 > > textmetrics=: ''&$: :{{ > NB. (max line width), height in pixels > NB. x: optional font spec > NB. y: newline delimited text > wd 'pc junk;cc z isidraw' > if. #x do. glfont x end. > (wd 'pclose') ] (>./glqextentw y),{.glqtextmetrics'' > }} > > minigantt=: {{ > pad=. 4 > 'w h'=. textmetrics ;({."1 y),each LF > guw=. h NB. gantt unit width > NB. 50 is arbitrary number to make window wide enough > W=. 50+(3*pad)+(>./w)+guw*1+>./;}."1 y > H=. pad+(#y)*pad+h > wd 'pc gantt closeok; minwh ',":W,H > wd 'cc chart isidraw; pshow' > gltextcolor glrgb 0 0 0 NB. black text > glbrush glrgb 0 0 255 NB. blue rectangles > glpen 1 NB. null pen - no outline on rectangles > X=. w+2*pad NB. screen location of x=0 for gantt rectangles > for_j. i.#y do. > Y=. pad+j*pad+h > gltextxy pad,Y > gltext (<j,0){::y > 'left right'=. ;}.j{y > glrect (X+guw*left),Y,(guw*right),h > end. > }} > > Run: > minigantt T > > to bring up a draft gantt chart. Note that I have assumed that numeric > values are reasonable here (positive but not too large). > > For some documentation on the drawing language I used here, see: > https://code.jsoftware.com/wiki/Guides/Window_Driver/Command_Reference > https://code.jsoftware.com/wiki/Guides/Window_Driver/gl2_Command_Reference > > Issues I ran into had to do with picking the right sizes for things. > There's some padding here that I have not spent enough time trying to > understand (that's where that 50 in minigantt comes from). Also, > there's a bug in the current implementation of glqtextmetrics which > needs to be worked around. > > Also, for more generic use it may be desirable to add support for > scrolling and/or paging and/or more labelling -- it might be desirable > to have an x axis, for example. > > And, I may have an inadvertent version dependency in this code which > will only show up in later J versions. > > Still, this at least shows a way that this kind of problem might be > approached. > > And, I think we need more of these kinds of problems, to work through > some of the issues which pop up when we make these attempts. > > Thanks, > > -- > Raul > > On Sat, Nov 13, 2021 at 7:48 PM Raul Miller <[email protected]> wrote: > > > > I wrote: > > > > On Sat, Nov 13, 2021 at 7:44 PM Raul Miller <[email protected]> wrote: > > > You could use viewmat to generate the bars horizontally. Though I > > > don't know how to put labels on a viewmat result. > > > > That was false: I do know how to put labels on a viewmat result. But I > > am usually too lazy to bother. > > > > (You start with a bitmap representation of each character you wish to > > include, and then you index them based on the characters in your text > > and update the relevant parts of your viewmat with those "pixels".) > > > > FYI, > > > > -- > > Raul > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
