一般来说,我很难理解如何构造我输入到 parseRawData 的数据项。但在这里我遇到了一个更简单的问题......我无法更改图表图例。我创建了这个可视化:
var appRetentionAndroidFunnelQry = new Keen.Query("funnel", {
steps: [
{
event_collection: "devices",
actor_property: "activationCode",
filters: [
{
"property_name": "action",
"operator": "eq",
"property_value": "Create"
},
{
"property_name": "platform",
"operator": "eq",
"property_value": "android"
}
],
timeframe: {
"start": periodRefStart.toISOString(),
"end": periodRefEnd.toISOString()
}
},
{
event_collection: "devices",
actor_property: "activationCode",
filters: [
{
"property_name": "action",
"operator": "eq",
"property_value": "Update"
},
{
"property_name": "platform",
"operator": "eq",
"property_value": "android"
}
],
timeframe: {
"start": period1Start.toISOString(),
"end": period1End.toISOString()
}
},
{
event_collection: "devices",
actor_property: "activationCode",
filters: [
{
"property_name": "action",
"operator": "eq",
"property_value": "Update"
},
{
"property_name": "platform",
"operator": "eq",
"property_value": "android"
}
],
timeframe: {
"start": period2Start.toISOString(),
"end": period2End.toISOString()
}
}
]
});
var appRetentionIosFunnelQry = new Keen.Query("funnel", {
steps: [
{
event_collection: "devices",
actor_property: "activationCode",
filters: [
{
"property_name": "action",
"operator": "eq",
"property_value": "Create"
},
{
"property_name": "platform",
"operator": "eq",
"property_value": "ios"
}
],
timeframe: {
"start": periodRefStart.toISOString(),
"end": periodRefEnd.toISOString()
}
},
{
event_collection: "devices",
actor_property: "activationCode",
filters: [
{
"property_name": "action",
"operator": "eq",
"property_value": "Update"
},
{
"property_name": "platform",
"operator": "eq",
"property_value": "ios"
}
],
timeframe: {
"start": period1Start.toISOString(),
"end": period1End.toISOString()
}
},
{
event_collection: "devices",
actor_property: "activationCode",
filters: [
{
"property_name": "action",
"operator": "eq",
"property_value": "Update"
},
{
"property_name": "platform",
"operator": "eq",
"property_value": "ios"
}
],
timeframe: {
"start": period2Start.toISOString(),
"end": period2End.toISOString()
}
}
]
});
var steps = [
periodRefStart.toISOString().slice(0, 10) + ' - ' + periodRefEnd.toISOString().slice(0, 10),
period1Start.toISOString().slice(0, 10) + ' - ' + period1End.toISOString().slice(0, 10),
period2Start.toISOString().slice(0, 10) + ' - ' + period2End.toISOString().slice(0, 10)
];
var combinedFunnel = new Keen.Dataviz()
.el(document.getElementById('app-retention-chart'))
.chartType('columnchart')
.chartOptions({
orientation: 'horizontal'
})
.height(250)
.prepare(); // start spinner
client.run([appRetentionAndroidFunnelQry, appRetentionIosFunnelQry], function (err, response) {
var output = {
result: [],
steps: []
};
// Combine results
Keen.utils.each(response[0].result, function (stepResult, i) {
output.result.push([
steps[i],
response[0].result[i],
response[1].result[i]
]);
});
// Draw custom data object
combinedFunnel
.parseRawData(output)
.render();
});
输出如下所示:
我怎样才能将图例和列标签更改为 Android 和 iOS 而不是 1 和 2?此外......任何有助于更好地理解数据解析器如何工作的帮助将不胜感激。我尝试阅读 parseRawData.js 源代码,但它似乎超出了我不太好的 JavaScript 能力。
问候, 哈立德