我下载了一个用户Keen.js为饼图提取数据的示例。
我只需要将一些数据硬编码到图表中,
例如50%通过,50%通过。
var pageviews_static = new Keen.Query("count", {
eventCollection: "pageviews",
groupBy: "user.device_info.browser.family",
timeframe: {
start: "2014-05-01T00:00:00.000Z",
end: "2014-05-05T00:00:00.000Z"
}
});
client.draw(pageviews_static, document.getElementById("chart-02"), {
chartType: "piechart",
title: false,
height: 250,
width: "auto",
chartOptions: {
chartArea: {
height: "85%",
left: "5%",
top: "5%",
width: "100%"
},
pieHole: .4
}
});
如何将pageview_static硬编码为50%传递,50%失败
答案 0 :(得分:4)
您可以自定义keen.js公开的Google图表选项。
数据的自定义标签:https://github.com/keen/keen-js/blob/master/docs/visualization.md#customized-labels
和自定义数据对象“Keen.Dataset:https://github.com/keen/keen-js/tree/master/docs/dataset#keendataset
var chart = new Keen.Dataviz()
.el(document.getElementById("chart"))
.chartType('piechart')
.parseRawData({ result: [
{ label: 'Pass', value: 50 },
{ label: 'Fail', value: 50 }
] })
.title('Pass/Fail Rate')
.height(240)
.render();