Attempting to hookup Keen javascript visualizer to two datasets, hitting errors in everything I've tried.
Tried using multi-analysis to get the response, this works but doesn't plug into the chart.
https://keen.io/docs/api/#multi-analysis
Also tried running separate queries and use client.run
on keen analysis client. Each query runs fine separately but when run together produces and error in the chart regarding timeframe.start
.
https://keen.io/docs/visualize/common-chart-examples/#area-step-chart-with-multiple-results
Tools:
"keen-analysis": "^3.4.0",
"keen-dataviz": "^3.5.3",
"keen-tracking": "^4.3.1",
Chart setup
const matchBreakdown = new keenDataviz({
container: "#match-breakdown",
type: "area-step",
title: "Match Breakdown (last 2 months)",
showLoadingSpinner: true
});
Multi-analysis attempt:
client
.query("multi_analysis", {
event_collection: "kitchen.matches",
analyses: {
"total_matches": {
analysis_type: "count",
filters: [
{"operator":"eq","property_name":"environment","property_value":"production"}
]
},
"bad_matches": {
analysis_type: "count",
filters: [
{"operator":"eq","property_name":"environment","property_value":"production"},
{"operator":"eq","property_name":"match_count","property_value":0}
]
}
},
timezone: "US/Mountain",
group_by: ["date"],
order_by: ["date"],
timeframe: "this_60_days"
})
.then(res => {
matchBreakdown.render(res);
})
.catch(err => {
// Source data is missing a component at (0,1)!
matchBreakdown.message(err.message);
});
Multiple queries attempt:
const allMatches = client
.query("count", {
event_collection: "kitchen.matches",
filters: [{"operator":"eq","property_name":"environment","property_value":"production"}],
group_by: ["date"],
order_by: ["date"],
timezone: "US/Mountain",
timeframe: "this_2_months"
});
const badMatches = client
.query("count", {
event_collection: "kitchen.matches",
filters: [
{"operator":"eq","property_name":"environment","property_value":"production"},
{"operator":"eq","property_name":"match_count","property_value":0}
],
group_by: ["date"],
order_by: ["date"],
timezone: "US/Mountain",
timeframe: "this_2_months"
});
client
.run([allMatches, badMatches])
.then(res => {
matchBreakdown.render(res);
})
.catch(error => {
// Cannot read property 'start' of undefined
matchBreakdown.message(error.message);
});
Note that this works:
client.run([badMatches]).then(res => {
matchBreakdown.render(res);
});
// Or this
client.run([allMatches]).then(res => {
matchBreakdown.render(res);
});
The examples give no further information on how to format response data, it seems like it should just work.