Fix broken charts with very long descriptions
This commit is contained in:
parent
36c5bed94e
commit
73bd63305b
1 changed files with 4 additions and 2 deletions
|
@ -24,10 +24,12 @@ var connection = mysql.createConnection(customvar1);
|
||||||
function plot(data) {
|
function plot(data) {
|
||||||
var dataToFeed = [];
|
var dataToFeed = [];
|
||||||
Object.keys(data).sort().forEach(function (key) {
|
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");
|
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"));
|
gnuplotObject.end(dataToFeed.join("\n"));
|
||||||
return gnuplotObject;
|
return gnuplotObject;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue