|
| 1 | +<div class="chart" id="keen-example-chart"></div> |
| 2 | +<div class="chart" id="backport-success">auto</div> |
| 3 | +<div class="flex-container" style="height: 340px"> |
| 4 | + <div class="item initial chart" id="keen-chart-2">auto</div> |
| 5 | + <div class="item auto chart" id="total-pr">auto</div> |
| 6 | +</div> |
| 7 | +<link |
| 8 | + href="https://d26b395fwzu5fz.cloudfront.net/keen-dataviz-1.1.3.css" |
| 9 | + rel="stylesheet" |
| 10 | +/> |
| 11 | + |
| 12 | +<style> |
| 13 | + .flex-container { |
| 14 | + margin-left: 25px; |
| 15 | + resize: horizontal; |
| 16 | + overflow: hidden; |
| 17 | + display: flex; |
| 18 | + } |
| 19 | + |
| 20 | + .initial { |
| 21 | + flex: initial; |
| 22 | + } |
| 23 | + |
| 24 | + .auto { |
| 25 | + width: 30%; |
| 26 | + margin: 10px; |
| 27 | + flex: auto; |
| 28 | + } |
| 29 | +</style> |
| 30 | +<script |
| 31 | + src="https://d26b395fwzu5fz.cloudfront.net/keen-analysis-1.2.2.js" |
| 32 | + type="text/javascript" |
| 33 | +></script> |
| 34 | +<script |
| 35 | + src="https://d26b395fwzu5fz.cloudfront.net/keen-dataviz-1.1.3.js" |
| 36 | + type="text/javascript" |
| 37 | +></script> |
| 38 | +<script type="text/javascript"> |
| 39 | + var client = new Keen({ |
| 40 | + projectId: "59e6286dc9e77c0001097979", |
| 41 | + readKey: |
| 42 | + "3ED31C47C7576FB00C2150C4DFE176EC96B379CE631051B89F83243160668F201FF1FCE12B97A5B579B4ACDA4282CD71BE218EF858963B70E89ACDFAEFE80053E9B6900C2DA61BD277F107B05D3ED16240DC5527B3C9BCCA6895DA8CF479B9E3", |
| 43 | + }); |
| 44 | + |
| 45 | + var chart = new Keen.Dataviz() |
| 46 | + .el("#keen-example-chart") |
| 47 | + .height(320) |
| 48 | + .title("Activity / repository / week on a 52 week period") |
| 49 | + .type("bar") |
| 50 | + .stacked(true) |
| 51 | + .prepare(); |
| 52 | + |
| 53 | + client |
| 54 | + .query("count", { |
| 55 | + event_collection: "dispatch", |
| 56 | + filters: [ |
| 57 | + { |
| 58 | + operator: "not_contains", |
| 59 | + property_name: "mention.repository", |
| 60 | + property_value: "/test1", |
| 61 | + }, |
| 62 | + ], |
| 63 | + group_by: ["mention.repository"], |
| 64 | + interval: "weekly", |
| 65 | + timeframe: "this_52_weeks", |
| 66 | + timezone: "US/Pacific", |
| 67 | + }) |
| 68 | + .then(function (res) { |
| 69 | + chart.data(res).render(); |
| 70 | + }) |
| 71 | + .catch(function (err) { |
| 72 | + chart.message(err.message); |
| 73 | + }); |
| 74 | + |
| 75 | + var chart2 = new Keen.Dataviz() |
| 76 | + .el("#keen-chart-2") |
| 77 | + .height(340) |
| 78 | + .width("400px") |
| 79 | + .title("Number of backport/Year/Project.") |
| 80 | + .type("table") |
| 81 | + .prepare(); |
| 82 | + |
| 83 | + client |
| 84 | + .query("count", { |
| 85 | + event_collection: "dispatch", |
| 86 | + filters: [ |
| 87 | + { |
| 88 | + operator: "contains", |
| 89 | + property_name: "mention.command", |
| 90 | + property_value: "backport", |
| 91 | + }, |
| 92 | + ], |
| 93 | + group_by: ["mention.organisation"], |
| 94 | + timeframe: "this_5_years", |
| 95 | + timezone: "US/Pacific", |
| 96 | + }) |
| 97 | + .then(function (res) { |
| 98 | + var data = chart2.data(res); |
| 99 | + console.log(data); |
| 100 | + data.dataset = data.dataset.sortRows("desc", function (arr) { |
| 101 | + console.log(arr); |
| 102 | + return arr[1]; |
| 103 | + }); |
| 104 | + data.dataset.matrix[0] = ["Organisation", "Backports"]; |
| 105 | + data.render(); |
| 106 | + }) |
| 107 | + .catch(function (err) { |
| 108 | + chart2.message(err.message); |
| 109 | + }); |
| 110 | + |
| 111 | + var chart3 = new Keen.Dataviz() |
| 112 | + .el("#total-pr") |
| 113 | + .height(340) |
| 114 | + .title("All attempted backports (excluding test repositories)") |
| 115 | + .type("metric") |
| 116 | + .prepare(); |
| 117 | + |
| 118 | + client |
| 119 | + .query("count", { |
| 120 | + event_collection: "dispatch", |
| 121 | + filters: [ |
| 122 | + { |
| 123 | + operator: "contains", |
| 124 | + property_name: "mention.command", |
| 125 | + property_value: "backport", |
| 126 | + }, |
| 127 | + { |
| 128 | + operator: "not_contains", |
| 129 | + property_name: "mention.repository", |
| 130 | + property_value: "test1", |
| 131 | + }, |
| 132 | + ], |
| 133 | + timeframe: "this_14_years", |
| 134 | + timezone: "US/Pacific", |
| 135 | + }) |
| 136 | + .then(function (res) { |
| 137 | + chart3.data(res).render(); |
| 138 | + }) |
| 139 | + .catch(function (err) { |
| 140 | + chart3.message(err.message); |
| 141 | + }); |
| 142 | + |
| 143 | + var chart4 = new Keen.Dataviz() |
| 144 | + .el("#backport-success") |
| 145 | + .height(240) |
| 146 | + .title("Backport Success") |
| 147 | + .stacked(true) |
| 148 | + .type("columnchart") |
| 149 | + .prepare(); |
| 150 | + |
| 151 | + client |
| 152 | + .query("count", { |
| 153 | + event_collection: "backport_stats", |
| 154 | + filters: [ |
| 155 | + { |
| 156 | + operator: "not_contains", |
| 157 | + property_name: "slug", |
| 158 | + property_value: "test1", |
| 159 | + }, |
| 160 | + { operator: "ne", property_name: "reason", property_value: "Sucess" }, |
| 161 | + ], |
| 162 | + group_by: ["reason"], |
| 163 | + interval: "weekly", |
| 164 | + timeframe: "this_52_weeks", |
| 165 | + timezone: "US/Pacific", |
| 166 | + }) |
| 167 | + .then(function (res) { |
| 168 | + chart4.data(res).render(); |
| 169 | + }) |
| 170 | + .catch(function (err) { |
| 171 | + chart.message(err.message); |
| 172 | + }); |
| 173 | +</script> |
0 commit comments