diff --git a/backend/serverSideScript.js b/backend/serverSideScript.js index 0192db0..89555a1 100644 --- a/backend/serverSideScript.js +++ b/backend/serverSideScript.js @@ -24,10 +24,12 @@ var connection = mysql.createConnection(customvar1); function plot(data) { var dataToFeed = []; Object.keys(data).sort().forEach(function (key) { - dataToFeed.push(dataToFeed.length + " \"" + key.replace(/"/g, "'") + "\" " + parseFloat(data[key])); + var feedKey = key.replace(/"/g, "'"); + if (feedKey.length > 32) feedKey = feedKey.substring(0, 32) + "..."; + dataToFeed.push(dataToFeed.length + " \"" + feedKey + "\" " + parseFloat(data[key])); }); if (dataToFeed.length == 0) dataToFeed.push("0 \"\" 0"); - var gnuplotObject = gnuplot().set("terminal png size 800,480").set("tics font \"Poppins,12\"").set("xtics rotate by 45 right").set("boxwidth 0.6").set("style fill solid").set("yrange [0:*]").set("grid ytics mytics").set("grid").plot("'-' using 1:3:xtic(2) notitle lc rgb \"#007000\" with boxes"); + var gnuplotObject = gnuplot().set("terminal png size 800,480").set("tics font \"Poppins,12\"").set("xtics rotate by 45 right").set("rmargin 3").set("boxwidth 0.6").set("style fill solid").set("yrange [0:*]").set("grid ytics mytics").set("grid").plot("'-' using 1:3:xtic(2) notitle lc rgb \"#007000\" with boxes"); gnuplotObject.end(dataToFeed.join("\n")); return gnuplotObject; }