Ezzmazz - 2019-05-13

Hello,

I have developped a CGI in bash/html that allow me to generate a graph of my clusters.

Here is an exemple :

This is a graph that works well. The problem is that for some graphs, the percentages overlap or shift far too far from where it should be. Here is my GNUPLOT code

f(w) = (strlen(w) > 10 ? word(w, 1) . "\n" . word(w, 2) : w)

set title "TITLE"
set terminal png truecolor size 960, 720 background rgb "#eff1f0"
set output "/var/www/html/CLUSTER_NAME.png"
set bmargin at screen 0.1
set key top center
set grid
set style data histograms
set style fill solid 1.00 border -1
set boxwidth 0.7 relative
set yrange [*:*]
set format y "%g%%"
set datafile separator ","
plot 'test1.txt' using 2:xtic(f(stringcolumn(1))) title " CPU consumption (%) ", \
'' using 3 title " RAM consumption (%)", \
'' using 0:($2+1):(sprintf(" %g%%",$2)) with labels notitle, \
'' using 0:($3+1):(sprintf("     %g%%",$3)) with labels notitle

Here is an example of a graph that does not work properly because the percentages are too shifted :

I am able to change this by changing this line in my code:

'' using 0:($3+1):(sprintf(" %g%%",$3)) with labels notitle

To :

'' using 0:($3+1):(sprintf("                               %g%%",$3)) with labels notitle

Adding spaces allows to shift the percentages :

But even if it works for this graph, it moves the percentages for the other graphs too... :

I can't get "clean" graphics. Either the percentages overlap, or they go out of scope because the values are too large, or they are completely shifted....

Another example:

Is there a way to make all this move by itself, automatically, according to the values and therefore the size of the bars etc?

Thanks ! :)