I want to create a boxplot graph using plotly.js and elasticsearch.
Elasticsearch has an inbuild boxplot aggregation that returns this for each trace:
{
"aggregations": {
"load_time_boxplot": {
"min": 0.0,
"max": 990.0,
"q1": 165.0,
"q2": 445.0,
"q3": 725.0,
"lower": 0.0,
"upper": 990.0
}
}
}
Right now i do something weird like this:
let polarityBuckets = i.aggregations.publisher.buckets;
let traces = {
max: polarityBuckets.map((e) => e.polarity["max"]),
min: polarityBuckets.map((e) => e.polarity["min"]),
q1: polarityBuckets.map((e) => e.polarity["q1"]),
median: polarityBuckets.map((e) => e.polarity["q2"]),
q3: polarityBuckets.map((e) => e.polarity["q3"]),
lowerfence: polarityBuckets.map((e) => {
if (e.polarity["lower"] == "NaN") {
return 0.0;
} else {
return e.polarity["lower"];
}
}),
upperfence: polarityBuckets.map((e) => e.polarity["upper"]),
name: "test",
type: "box",
};
But thats not even working, the graph looks so faulty.
I dont even know if max and min exist. The plotly boxplot config doesnt show min or max options, but when I hover over a trace it gives me the values for upper, lower … etc and min and max aswell.
Please help me on how to correctly and simply use the elasticsearch boxplot aggregation as one trace?
Thank you