I would like to create active content evaluations of KPIs. For that I would like to use the mouse over function as availabe e.g. for the point style (hypertext.dem).
Is or will this be available for bargraphs also? I the plot I see a popup displaying my "using" statements, but I did not find a way to modify it with the "with labels hypertext" statements.
The only workaround I see for now is to add another plot on top with point style that would popup the hypertext.
I tried things in gnuplot version 6.0 and 6.0.2.
Here is a script that I generated (tipps from theozh included):
reset session
set datafile separator ","
set xtics nomirror rotate by 0
set style data histogram
set style histogram rowstacked title textcolor lt -1
set boxwidth 0.75
set style fill solid 0.3 border
unset key
set key noautotitle
# I need a lookup table to show relevant text to the KPIs in columns 6 and every 3rd column thereafter to 23*3
array Cat[4000]
Cat[1]=''
Cat[1110]='Text 1110'
Cat[1122]='this means something 1122'
Cat[1123]='this means sth different 1123'
Cat[1124]='this yet means sth slightly different 1123'
Cat[2242]='Here some more text 2242'
Cat[2230]='Here some more text 2230'
Cat[3340]='has another meaning 3340'
Cat[4000]='Text_4000'
Cat2label(position) = sprintf("%d\n%s", column(position),Cat[column(position)])
set output "KPI_2025_02.svg"
set term svg size 1280,300 mousing jsdir './js/'
set style histogram rowstacked title textcolor lt -1
# I need a multiplot, because more is shown (not relevant here)
set multiplot layout 1,2
set bmargin 1.6
set size 0.85,1.000000
set origin 0,0.000000
#this plots stacked vertical bars up to 24h, one per day (x-direction), additionally KPI short text is plotted as labels
p [-0.5:31.5][0:24]\
for [i=0:23] "datafile_gp.dat" u i*3+4:i*3+5:xtic(sprintf("%02d",$3)) lc variable, \
for [i=0:23] "datafile_gp.dat" u :(((Cat2label(i*3+6))!=1) ? (sum [k=0:i] column(3*k+4)) : 3/0):i*3+6 w labels font "arial,8" tc rgb "black" offset -0.1,-0.25
set size 0.85,1.000000
set origin 0.0,0.000000
#this is the critical part that should generate the hypertext popups:
p [-0.5:31.5][0:24]\
for [i=0:23] "datafile_gp.dat" u ($0+0.4):(((Cat2label(i*3+6))!="1") ? (sum [k=0:i] column(k*3+4))-0.5 : 3/0):(Cat2label(i*3+6)):i*3+5 lc variable with labels hypertext point pt 5 ps 0.5
unset multiplot
And here my datafile that needs to be saved as "datafile_gp.dat":
2025,02,01,24.0,3,2242, 0.0,0, 1, 0.0,0, 1, 0.0,0, 1, 0.0,0, 1, 0.0,0, 1, 0.0,0, 1, 0.0,0, 1, 0.0,0, 1, 0.0,0, 1, 0.0,0, 1, 0.0,0, 1, 0.0,0, 1, 0.0,0, 1, 0.0,0, 1, 0.0,0, 1, 0.0,0, 1, 0.0,0, 1, 0.0,0, 1, 0.0,0, 1, 0.0,0, 1, 0.0,0, 1, 0.0,0, 1, 0.0,0, 1, 0.0,0, 1
2025,02,02,24.0,3,2242, 0.0,0, 1, 0.0,0, 1, 0.0,0, 1, 0.0,0, 1, 0.0,0, 1, 0.0,0, 1, 0.0,0, 1, 0.0,0, 1, 0.0,0, 1, 0.0,0, 1, 0.0,0, 1, 0.0,0, 1, 0.0,0, 1, 0.0,0, 1, 0.0,0, 1, 0.0,0, 1, 0.0,0, 1, 0.0,0, 1, 0.0,0, 1, 0.0,0, 1, 0.0,0, 1, 0.0,0, 1, 0.0,0, 1, 0.0,0, 1
2025,02,03, 6.0,3,2242, 1.0,3,2230, 5.0,2,1110, 3.0,2,1122, 2.0,3,2230, 7.0,3,2242, 0.0,0, 1, 0.0,0, 1, 0.0,0, 1, 0.0,0, 1, 0.0,0, 1, 0.0,0, 1, 0.0,0, 1, 0.0,0, 1, 0.0,0, 1, 0.0,0, 1, 0.0,0, 1, 0.0,0, 1, 0.0,0, 1, 0.0,0, 1, 0.0,0, 1, 0.0,0, 1, 0.0,0, 1, 0.0,0, 1, 0.0,0, 1
2025,02,04, 6.0,3,2242, 1.0,3,2230, 3.0,2,1122, 2.0,2,1123, 1.0,1,3340, 1.0,2,1124, 2.0,2,1110, 1.0,2,1122, 7.0,3,2242, 0.0,0, 1, 0.0,0, 1, 0.0,0, 1, 0.0,0, 1, 0.0,0, 1, 0.0,0, 1, 0.0,0, 1, 0.0,0, 1, 0.0,0, 1, 0.0,0, 1, 0.0,0, 1, 0.0,0, 1, 0.0,0, 1, 0.0,0, 1, 0.0,0, 1, 0.0,0, 1
A solution to this questions probably requires some "tricks". As far as I know, with labels hypertext
can only use anchor points. It would be nice if there might be a feature for hypertext for arbitrary areas, e.g. like filledcurves on a map (maybe in the future?). However, it wouldn't be gnuplot if there isn't a workaround. At least for the simpler case of bars or rectangles.
So, if your mouse is above the anchor point, the hypertext will be displayed.
pointtype
, e.g. pt 5
is a filled squarepointsize
, e.g. ps 5
Hence, for the simplest case
lc rgb 0xff123456
, the mouse will still react, although the point is invisibleThis will look like this: (just for illustration, the alpha channel is not set to full transparency, but only to 0xee
).
The corresponding part of the plot command would look like this:
'' u 1:2:2 w labels hypertext point pt 5 ps 5 lc rgb 0xee123456
However, if you want the whole bar to react to mouse hovering, simply place several anchor points on top of each bar.
Script:
### hypertext for the whole area of bar grahps
reset session
# create some random test data
set table $Data
set samples 9
plot '+' u ($0+1):(rand(0)*10+1) w table
unset table
set boxwidth 0.9
set style fill solid 0.5
set yrange[0:]
set key noautotitle
stats $Data u 2 nooutput
Nmax = 8
dy0 = STATS_max/(Nmax-1)
plot $Data u 1:2 w boxes lc rgb 0xff0000, \
for [i=0:Nmax] $Data u 1:(dy=$2/ceil($2/dy0), i*dy>1.1*$2 ? NaN : i*dy):2 \
w labels hypertext point pt 5 ps 5 lc rgb 0xee123456
### end of script
Result:
Screenshot from qt terminal:
Unfortunately, you cannot upload SVGs in StackOverflow, hence, here a screen capture from SVG in Firefox browser: set color to full transparency, i.e. lc rgb 0xff123456
to let the squares disappear.
For creating a SVG, modify the script to something like this:
...
set term svg mouse standalone
set output "SO79497533.svg"
plot ...
set output