1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
|
/*
* kintone dashboard sample program
* Copyright (c) 2016 Cybozu
*
* Licensed under the MIT License
* https://opensource.org/license/mit/
*/
/* eslint-disable max-statements */
/* global Kucs */
/* global luxon */
(() => {
'use strict';
const Kuc = Kucs['1.7.0'];
// 販売実績アプリID
const SALES_APPID = {販売実績アプリID};
// 試用申し込み管理アプリID
const TRIAL_APPID = {試用申し込み管理アプリID};
let oneTimeFlg = true;
let chart1, chart2, chart3;
// luxonで使用する日付フォーマット
const dateFormat = 'yyyy-MM-dd';
const dateFormatM1 = 'M月';
const dateFormatM2 = 'M';
const dateFormatY = 'yyyy';
const endOfFormatM = 'month';
// ローディング画面を出す関数
const setLoading = () => {
const $body = $('body');
$body.css('width', '100%');
// eslint-disable-next-line max-len
const $loading = $('<div>').attr('id', 'loading').attr('class', 'loading').attr('style', 'width: 100%; height: 100%; position:absolute; top:0; left:0; text-align:center; background-color:#666666; opacity:0.6; z-index: 9;');
const $div = $('<div>').attr('id', 'imgBox').attr('style', 'width: 100%; height: 100%;');
// eslint-disable-next-line max-len
const $img = $('<img>').attr('src', 'data:image/gif;base64,R0lGODlhZABkAPQAAAAAAP///3BwcJaWlsjIyMLCwqKiouLi4uzs7NLS0qqqqrKysoCAgHh4eNra2v///4iIiLq6uvT09AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH+GkNyZWF0ZWQgd2l0aCBhamF4bG9hZC5pbmZvACH5BAAHAAAAIf8LTkVUU0NBUEUyLjADAQAAACwAAAAAZABkAAAF/yAgjmRpnmiqrmzrvnAsz3Rt33iu73zfMgoDw0csAgSEh/JBEBifucRymYBaaYzpdHjtuhba5cJLXoHDj3HZBykkIpDWAP0YrHsDiV5faB3CB3c8EHuFdisNDlMHTi4NEI2CJwWFewQuAwtBMAIKQZGSJAmVelVGEAaeXKEkEaQSpkUNngYNrCWEpIdGj6C3IpSFfb+CAwkOCbvEy8zNzs/Q0dLT1NUrAgOf1kUMBwjfB8rbOQLe3+C24wxCNwPn7wrjEAv0qzMK7+eX2wb0mzXu8iGIty1TPRvlBKazJgBVnBsN8okbRy6VgoUUM2rcyLGjx48gQ4ocSbKkyZMoJf8JMFCAwAJfKU0gOUDzgAOYHiE8XDGAJoKa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OHECNKnEixosWLGDNq3MjxCIRiHV0wIIAAQQKAIVX/MDhQsqQElBUFNFCAjUWBli0dGGSEyUQbn2xKOOI5IigAo0V/pmBQIEIBgigg4MS5MynQoz1FBEWKtatVrVuzel2h4GlTflGntnzGFexYrErdckXaiGjbEv6aEltxc+qbFHfD2hUr+GvXuIfFmmD6NEJVEg1Y4oQJtC3ixDwtZzWqWfGJBksajmhA0iTllCk+ikbNurXr17Bjy55Nu7bt20HkKGCwOiWDBAeC63S4B1vvFAIIBF+e4DEuAQsISCdHI/Ly5ad1QZBeQLrzMssRLFdgDKF0AgUUybB+/YB6XiO7Sz9+QkAE8cEREPh+y8B5hjbYtxxU6kDQAH3I7XEgnG4MNujggxBGCAVvt2XhwIUK8JfEIX3YYsCFB2CoRwEJJEQAgkM0ANyFLL7HgwElxphdGhCwCKIDLu4QXYwEUEeJAAnc6EACOeowAI8n1TKAjQ74uIIAo9Bnn4kRoDgElEEmQIULNWY54wkMjAKSLQq+IMCQQwZp5UVdZpnkbBC4OeSXqCXnJpG1qahQc7c1wAADGkoo6KCEFrpCCAA7AAAAAAAAAAAA');
$loading.append($div.append($img));
$body.append($loading);
$('#imgBox').attr('style', 'margin-top: ' + Math.floor($('#loading').height() / 2) + 'px;');
$body.css('position', 'fixed');
};
// ローディング画面を消す関数
const removeLoading = () => {
const $loading = $('.loading');
$loading.remove();
const $body = $('body');
$body.css('position', '');
};
// dataオブジェクトの中身を消す関数
const refreshData = (data) => {
for (const key in data) {
if (Object.prototype.hasOwnProperty.call(data, key)) {
data[key] = 0;
}
}
return data;
};
// レコード取得用クエリ作成
const strQuery = (dateS, dateE) => `日付 <= "${dateE}" and 日付 >= "${dateS}"`;
// 全レコード取得関数
const fetchRecords = async (appId, query, orderField) => {
const client = new KintoneRestAPIClient();
const params = {
app: appId,
condition: query,
orderBy: orderField
};
return await client.record.getAllRecordsWithOffset(params);
};
// DatePicker設置
const createDatePicker = () => {
const datePickerMax = new Kuc.DatePicker({
value: luxon.DateTime.local().toFormat(dateFormat),
id: 'datePickerMax'
});
$('#datepicker').append(datePickerMax);
datePickerMax.addEventListener('change', event => {
createCompareGraph(datePickerMax.value);
});
oneTimeFlg = false;
};
// グラフを描画する
const createCompareGraph = async (max) => {
setLoading();
const maxDateTime = max ? luxon.DateTime.fromFormat(max, dateFormat) : luxon.DateTime.local();
const minDateTime = maxDateTime.minus({months: 11});
// 'yyyy-MM-dd'フォーマットの文字列
const maxMonth = maxDateTime.endOf(endOfFormatM).toFormat(dateFormat);
const maxMonth2 = maxDateTime.minus({months: 12}).endOf(endOfFormatM).toFormat(dateFormat);
const minMonth = maxDateTime.minus({months: 11}).startOf(endOfFormatM).toFormat(dateFormat);
const minMonth2 = maxDateTime.minus({months: 23}).startOf(endOfFormatM).toFormat(dateFormat);
// 11ヶ月前,10ヶ月前,....,1ヶ月前,今月 の順に、12ヶ月分が 'M月'フォーマットで格納されている配列
const nMonthsBefore = Array(12).fill().map((e, i)=>maxDateTime.minus({months: i}).toFormat(dateFormatM1)).reverse();
// 日付昇順にするので
const orderField = '日付';
// 指定日~1年前までの売上レコード取得
const canvas1Rec = await fetchRecords(SALES_APPID, strQuery(minMonth, maxMonth), orderField);
// 1年前~2年前までの売上レコード取得
const canvas1Rec2 = await fetchRecords(SALES_APPID, strQuery(minMonth2, maxMonth2), orderField);
// 指定日~1年前までの試用申込数レコード取得
const canvas2Rec = await fetchRecords(TRIAL_APPID, strQuery(minMonth, maxMonth), orderField);
// グラフデータ作成用にテンポラリとして使うdataオブジェクト
let data = [];
nMonthsBefore.forEach(el=>{
data[el] = 0;
});
// 今月~1年前までの売上グラフデータ作成
canvas1Rec.forEach(e=>{
data[luxon.DateTime.fromFormat(e.日付.value, dateFormat).toFormat(dateFormatM1)] += Number(e.販売額.value);
});
// 今月~1年前までの売上グラフデータ
const eventuallyThisYearData = nMonthsBefore.map((e)=>data[e]);
// dataを初期化
data = refreshData(data);
// 1年前~2年前までの売上グラフのデータ作成
canvas1Rec2.forEach(e=>{
data[luxon.DateTime.fromFormat(e.日付.value, dateFormat).toFormat(dateFormatM1)] += Number(e.販売額.value);
});
// 1年前~2年前までの売上グラフのデータ
const eventuallyLastYearData = nMonthsBefore.map((e)=>data[e]);
// dataを初期化
data = refreshData(data);
// 指定日~1年前までの試用申込数グラフのデータ作成
canvas2Rec.forEach(e=>{
data[luxon.DateTime.fromFormat(e.日付.value, dateFormat).toFormat(dateFormatM1)] += 1;
});
// 指定日~1年前までの試用申込数グラフデータ
const eventuallyTrialData = nMonthsBefore.map(e=>data[e]);
// ドーナツグラフのデータ作成
const prodData = [];
const prodLabels = [];
canvas1Rec.forEach(e=>{
const prod = e.製品名.value;
if (typeof (prodData[prod]) === 'undefined') {
prodData[prod] = 0;
prodLabels.push(prod);
}
prodData[prod] += Number(e.販売額.value);
});
// 製品名ラベル表示順を売上データ降順にソート
prodLabels.sort((a, b) => prodData[b] - prodData[a]);
// 製品ごとの背景色
const prodBGColorMST = {
製品A: 'rgba(54, 162, 235, 0.4)',
製品B: 'rgba(255, 99, 132, 0.4)',
製品C: 'rgba(0, 100, 0, 0.4)',
製品D: 'rgba(255, 60, 255, 0.4)',
製品E: 'rgba(255, 255, 0, 0.4)',
製品F: 'rgba(255, 112, 0, 0.4)',
製品G: 'rgba(60, 60, 120, 0.4)',
製品H: 'rgba(255, 0, 0, 0.4)',
製品I: 'rgba(0, 255, 255, 0.4)'
};
/*
// 【参考】製品縁取り色
const prodBDColorMST = {
製品A:"rgba(54, 162, 235, 1)",
製品B:"rgba(255,99,132,1)",
製品C:"rgba(0, 170, 0, 1)",
製品D:"rgba(255, 170, 255, 1)",
製品E:"rgba(255, 255, 0, 1)",
製品F:"rgba(255, 112, 0, 1)",
製品G:"rgba(100, 0, 0, 1)",
製品H:"rgba(255, 184, 184, 1)",
製品I:"rgba(0, 255, 255, 1)"
};
*/
// ドーナツグラフのデータ
const eventuallyByProductData = prodLabels.map(e=>prodData[e]);
const sumOfeventuallyByProductData = eventuallyByProductData.reduce((a, c)=>a + c, 0);
const prodBGColor = prodLabels.map(e=>prodBGColorMST[e]);
// const prodBDColor = prodLabels.map(e=>prodBDColorMST[e]);
// 前年同月比グラフを描画(1つ目のグラフ)
const ctx = document.getElementById('canvas1');
if (chart1) {
chart1.destroy();
}
chart1 = new Chart(ctx, {
type: 'bar',
data: {
labels: nMonthsBefore,
datasets: [
{
label: '前年同月売上',
data: eventuallyLastYearData,
backgroundColor: 'rgba(54, 162, 235, 0.2)',
borderColor: 'rgba(54, 162, 235, 1)',
borderWidth: 1,
test: 'aiueo'
},
{
label: minDateTime.toFormat('yyyy年M月~') + maxDateTime.toFormat('yyyy年M月売上'),
data: eventuallyThisYearData,
backgroundColor: 'rgba(255, 99, 132, 0.2)',
borderColor: 'rgba(255,99,132,1)',
borderWidth: 1,
test: 'ABCDE'
}
]
},
options: {
scales: {
yAxes: [{
display: true,
scaleLabel: {
display: true,
labelString: '売上',
fontFamily: 'monospace'
},
ticks: {
beginAtZero: true,
maxTicksLimit: 8,
callback: (value) => value + '万円'
}
}]
},
tooltips: {
enabled: true,
mode: 'single',
callbacks: {
title: (tooltipItems, titleData) => {
const tmp = tooltipItems[0].xLabel.split('月');
// 1) tooltipItems[0].datasetIndex 0:指定日(maxDateTime)の前年、1:指定日(maxDateTime)の年
// 2) tooltipItems[0].xLabelの月がmaxDateTimeより大きかったら-1年にする
let retYear = maxDateTime.minus({years: 1}).toFormat(dateFormatY);
if (Number(tmp[0]) > Number(maxDateTime.toFormat(dateFormatM2))) {
if (tooltipItems[0].datasetIndex === 0) {
retYear = maxDateTime.minus({years: 2}).toFormat(dateFormatY);
}
} else if (tooltipItems[0].datasetIndex === 1) {
retYear = maxDateTime.toFormat(dateFormatY);
}
return `${retYear}年${tooltipItems[0].xLabel}`;
},
label: (tooltipItems, data3) => tooltipItems.yLabel + '万円'
}
}
}
});
// 売上と試用申込数グラフを描画(2つ目のグラフ)
const ctx2 = document.getElementById('canvas2');
if (chart2) {
chart2.destroy();
}
chart2 = new Chart(ctx2, {
type: 'bar',
data: {
labels: nMonthsBefore,
datasets: [
{
yAxisID: 'y-axis-1',
type: 'line',
label: '試用申込数',
data: eventuallyTrialData,
backgroundColor: 'rgba(54, 162, 235, 0.2)',
borderColor: 'rgba(54, 162, 235, 1)',
borderWidth: 1
},
{
yAxisID: 'y-axis-0',
type: 'bar',
label: minDateTime.toFormat('yyyy年M月~') + maxDateTime.toFormat('yyyy年M月売上'),
data: eventuallyThisYearData,
backgroundColor: 'rgba(255, 99, 132, 0.2)',
borderColor: 'rgba(255,99,132,1)',
borderWidth: 1
}
]
},
options: {
scales: {
yAxes: [{
position: 'left',
id: 'y-axis-0',
display: true,
scaleLabel: {
display: true,
labelString: '売上',
fontFamily: 'monospace'
},
ticks: {
beginAtZero: true,
maxTicksLimit: 8,
callback: (value) => value + '万円'
}
},
{
position: 'right',
id: 'y-axis-1',
display: true,
scaleLabel: {
display: true,
labelString: '試用申込数',
fontFamily: 'monospace'
},
ticks: {
beginAtZero: true,
maxTicksLimit: 6
}
}]
},
tooltips: {
enabled: true,
mode: 'single',
callbacks: {
title: (tooltipItems, data4) => {
const tmp = tooltipItems[0].xLabel.split('月');
// tooltipItems[0].xLabelの月がmaxDateTimeより大きかったら-1年する
// eslint-disable-next-line max-len
const retYear = Number(tmp[0]) > Number(maxDateTime.toFormat(dateFormatM2)) ? maxDateTime.minus({years: 1}).toFormat(dateFormatY) : maxDateTime.toFormat(dateFormatY);
return `${retYear}年${tooltipItems[0].xLabel}`;
},
label: (tooltipItems, data5) => {
if (tooltipItems.datasetIndex === 0) {
return `試用申込数:${tooltipItems.yLabel}`;
}
return `売上:${tooltipItems.yLabel}万円`;
}
}
}
}
});
// ドーナツグラフを描画
const ctx3 = document.getElementById('canvas3');
if (chart3) {
chart3.destroy();
}
chart3 = new Chart(ctx3, {
type: 'doughnut',
data: {
labels: prodLabels,
datasets: [
{
data: eventuallyByProductData,
backgroundColor: prodBGColor,
// borderColor: prodBDColor,
borderWidth: 1
}
]
},
options: {
showAllTooltips: true,
animation: {
animateScale: true
},
tooltips: {
callbacks: {
title: (tooltipItems, data6) => {
return data6.labels[tooltipItems[0].index];
},
label: (tooltipItems, data7) => {
const per = Math.round((data7.datasets[0].data[tooltipItems.index] / sumOfeventuallyByProductData * 100));
return `${per}% ${data7.datasets[0].data[tooltipItems.index]}万円`;
}
}
}
}
});
// グラフのデフォルトフォントサイズ設定
Chart.defaults.global.defaultFontSize = 10;
// datePickerの作成は画面読み込み時のみ
if (oneTimeFlg) {
createDatePicker();
}
removeLoading();
};
/*
// 【参考】ドーナツグラフの各製品色をランダムに決定する関数
const dynamicColors = () => {
const r = Math.floor(Math.random() * 255);
const g = Math.floor(Math.random() * 255);
const b = Math.floor(Math.random() * 255);
return `rgb(${r},${g},${b})`;
}
// 【参考】ドーナツグラフの各項目を常に表示
Chart.pluginService.register({
beforeRender: (chart) => {
if (chart.config.options.showAllTooltips) {
chart.pluginTooltips = [];
chart.config.data.datasets.forEach((dataset, i) => {
chart.getDatasetMeta(i).data.forEach((sector, j) => {
chart.pluginTooltips.push(new Chart.Tooltip({
_chart: chart.chart,
_chartInstance: chart,
_data: chart.data,
_options: chart.options.tooltips,
_active: [sector]
}, chart));
});
});
chart.options.tooltips.enabled = false;
}
},
afterDraw: (chart, easing) => {
if (chart.config.options.showAllTooltips) {
if (!chart.allTooltipsOnce) {
if (easing !== 1) return;
chart.allTooltipsOnce = true;
}
chart.options.tooltips.enabled = true;
Chart.helpers.each(chart.pluginTooltips, (tooltip) => {
tooltip.initialize();
tooltip.update();
tooltip.pivot();
tooltip.transition(easing).draw();
});
chart.options.tooltips.enabled = false;
}
}
});
*/
kintone.events.on('app.record.index.show', (event) => {
if (event.viewName === 'ダッシュボード') {
createCompareGraph();
}
return event;
});
})();
|