Cloud computing platform
Révision | 1f22eb7c0b4ccf2727bac6c8cf3ded82e300f104 (tree) |
---|---|
l'heure | 2016-04-27 08:15:29 |
Auteur | naoki hirata <naoki@magi...> |
Commiter | naoki hirata |
ブログメインウィジェット更新。
@@ -25,8 +25,10 @@ class admin_blog_mainAnalyticsWidgetContainer extends admin_blog_mainBaseWidgetC | ||
25 | 25 | private $termTypeArray; // 期間タイプ |
26 | 26 | private $calcType; // 選択中の集計タイプ |
27 | 27 | private $termType; // 選択中の期間タイプ |
28 | - private $yTickValueArray; // Y軸の最大値リスト | |
28 | + private $yMaxTickArray; // Y軸の最大値リスト | |
29 | 29 | private $weekTypeArray; // 曜日表示名 |
30 | + private $xTitleArray; // X軸値 | |
31 | + private $yValueArray; // Y軸値 | |
30 | 32 | private $maxViewCount; // コンテン参照数最大値 |
31 | 33 | private $graphDataKeyArray; // グラフデータ取得用キー |
32 | 34 | private $graphDataArray; // グラフデータ(X軸値をキー、Y軸値を値とする連想配列) |
@@ -75,7 +77,7 @@ class admin_blog_mainAnalyticsWidgetContainer extends admin_blog_mainBaseWidgetC | ||
75 | 77 | array( 'name' => 'すべて', 'value' => self::TERM_TYPE_ALL)); |
76 | 78 | |
77 | 79 | // Y軸の最大値リスト |
78 | - $this->yTickValueArray = array(1000000, 500000, 100000, 50000, 10000, 5000, 1000, 500, 100, 0); | |
80 | + $this->yMaxTickArray = array(1000000, 500000, 100000, 50000, 10000, 5000, 1000, 500, 100, 0); | |
79 | 81 | |
80 | 82 | // 曜日表示名 |
81 | 83 | $this->weekTypeArray = array('日', '月', '火', '水', '木', '金', '土'); |
@@ -197,110 +199,19 @@ class admin_blog_mainAnalyticsWidgetContainer extends admin_blog_mainBaseWidgetC | ||
197 | 199 | // 集計タイプメニュー作成 |
198 | 200 | $this->createCalcTypeMenu(); |
199 | 201 | |
200 | - // ##### 集計グラフ作成 ##### | |
201 | - $xTitleArray = array(); | |
202 | - $yValueArray = array(); | |
203 | - $this->graphDataKeyArray = array(); // グラフデータ取得用キー | |
204 | - | |
205 | - // 集計グラフ用データ取得 | |
206 | - if ($this->calcType == 'day'){ // 日単位で集計の場合 | |
207 | - $this->db->getAllContentViewCountByDate(blog_mainCommonDef::VIEW_CONTENT_TYPE, $this->startDate, $this->endDate, array($this, 'contentViewCountLoop')); | |
208 | - | |
209 | - // X軸ラベル作成 | |
210 | - $dateTimestamp = strtotime($this->startDate); | |
211 | - $startTimestamp = $dateTimestamp; | |
212 | - $endTimestamp = strtotime($this->endDate); | |
213 | - $date = $this->startDate; | |
214 | - $graphDataKey = date($this->graphDataKeyFormat, $dateTimestamp); | |
215 | - while (true){ | |
216 | - if ($dateTimestamp > $endTimestamp) break; | |
217 | - $this->graphDataKeyArray[] = $graphDataKey; // グラフデータ取得用キー | |
218 | - | |
219 | - // グラフ用のデータ作成 | |
220 | - $xTitleArray[] = date('n/j', $dateTimestamp); // X軸タイトル。表示フォーマットに変換。 | |
221 | - $value = $this->graphDataArray[$graphDataKey]; | |
222 | - if (isset($value)){ | |
223 | - $yValueArray[] = intval($value); | |
224 | - } else { | |
225 | - $yValueArray[] = 0; | |
226 | - } | |
227 | - $dateTimestamp = strtotime("$date 1 day"); | |
228 | - $date = date(self::DATE_FORMAT, $dateTimestamp); // 次の日に更新 | |
229 | - $graphDataKey = date($this->graphDataKeyFormat, $dateTimestamp); | |
230 | - } | |
231 | - } else if ($this->calcType == 'month'){ // 月単位で集計の場合 | |
232 | - $this->db->getAllContentViewCountByMonth(blog_mainCommonDef::VIEW_CONTENT_TYPE, $this->startDate, $this->endDate, array($this, 'contentViewCountLoop')); | |
233 | - | |
234 | - // X軸ラベル作成 | |
235 | - $year = $startYear; | |
236 | - $month = $startMonth; | |
237 | - $dateTimestamp = strtotime("$year-$month-1"); | |
238 | - $graphDataKey = date($this->graphDataKeyFormat, $dateTimestamp); | |
239 | - | |
240 | - for ($i = 0; $i < 12; $i++){ | |
241 | - $this->graphDataKeyArray[] = $graphDataKey; // グラフデータ取得用キー | |
242 | - | |
243 | - // グラフ用のデータ作成 | |
244 | - $xTitleArray[] = date('n月', $dateTimestamp); // X軸タイトル。表示フォーマットに変換。 | |
245 | - $value = $this->graphDataArray[$graphDataKey]; | |
246 | - if (isset($value)){ | |
247 | - $yValueArray[] = intval($value); | |
248 | - } else { | |
249 | - $yValueArray[] = 0; | |
250 | - } | |
251 | - | |
252 | - // 次の月へ進む | |
253 | - $month++; | |
254 | - if ($month > 12){ | |
255 | - $month = 1; | |
256 | - $year++; | |
257 | - } | |
258 | - $dateTimestamp = strtotime("$year-$month-1"); | |
259 | - $graphDataKey = date($this->graphDataKeyFormat, $dateTimestamp); | |
260 | - } | |
261 | - } else if ($this->calcType == 'hour'){ // 時間単位で集計の場合 | |
262 | - $this->db->getAllContentViewCountByHour(blog_mainCommonDef::VIEW_CONTENT_TYPE, $this->startDate, $this->endDate, array($this, 'contentViewCountLoop')); | |
263 | - | |
264 | - // X軸ラベル作成 | |
265 | - for ($i = 0; $i < 24; $i++){ | |
266 | - $this->graphDataKeyArray[] = $i; // グラフデータ取得用キー | |
267 | - | |
268 | - // グラフ用のデータ作成 | |
269 | - $xTitleArray[] = $i . '時'; // X軸タイトル(時間) | |
270 | - $value = $this->graphDataArray[$i]; | |
271 | - if (isset($value)){ | |
272 | - $yValueArray[] = intval($value); | |
273 | - } else { | |
274 | - $yValueArray[] = 0; | |
275 | - } | |
276 | - } | |
277 | - } else if ($this->calcType == 'week'){ // 曜日単位で集計の場合 | |
278 | - $this->db->getAllContentViewCountByWeek(blog_mainCommonDef::VIEW_CONTENT_TYPE, $this->startDate, $this->endDate, array($this, 'contentViewCountLoop')); | |
279 | - | |
280 | - // X軸ラベル作成 | |
281 | - for ($i = 0; $i < 7; $i++){ | |
282 | - $this->graphDataKeyArray[] = $i; // グラフデータ取得用キー | |
283 | - | |
284 | - // グラフ用のデータ作成 | |
285 | - $xTitleArray[] = $this->weekTypeArray[$i]; // X軸タイトル(曜日) | |
286 | - $value = $this->graphDataArray[$i]; | |
287 | - if (isset($value)){ | |
288 | - $yValueArray[] = intval($value); | |
289 | - } else { | |
290 | - $yValueArray[] = 0; | |
291 | - } | |
292 | - } | |
293 | - } | |
202 | + // ##### グラフ用データ作成 ##### | |
203 | + $this->createGraphData(); | |
294 | 204 | |
295 | 205 | // グラフ用データをスクリプト化 |
296 | - $graphDataXStr = '[' . implode(', ', array_map(create_function('$a','return "\'" . $a . "\'";'), $xTitleArray)) . ']'; | |
297 | - $graphDataYStr = '[' . implode(', ', $yValueArray) . ']'; | |
206 | + $graphDataXStr = '[' . implode(', ', array_map(create_function('$a','return "\'" . $a . "\'";'), $this->xTitleArray)) . ']'; | |
207 | + $graphDataYStr = '[' . implode(', ', $this->yValueArray) . ']'; | |
208 | + $graphDataKeyStr = '[' . implode(', ', array_map(create_function('$a','return "\'" . $a . "\'";'), $this->graphDataKeyArray)) . ']'; | |
298 | 209 | |
299 | 210 | // グラフY座標最大値取得 |
300 | 211 | $yMax = self::DEFAULT_Y_TICK_VALUE; |
301 | - for ($i = 0; $i < count($this->yTickValueArray) -1; $i++){ | |
302 | - if ($this->maxViewCount >= $this->yTickValueArray[$i + 1]){ | |
303 | - $yMax = $this->yTickValueArray[$i];// Y座標最大値 | |
212 | + for ($i = 0; $i < count($this->yMaxTickArray) -1; $i++){ | |
213 | + if ($this->maxViewCount >= $this->yMaxTickArray[$i + 1]){ | |
214 | + $yMax = $this->yMaxTickArray[$i];// Y座標最大値 | |
304 | 215 | break; |
305 | 216 | } |
306 | 217 | } |
@@ -314,11 +225,11 @@ class admin_blog_mainAnalyticsWidgetContainer extends admin_blog_mainBaseWidgetC | ||
314 | 225 | } |
315 | 226 | |
316 | 227 | // X軸タイトル作成 |
317 | - array_unshift($xTitleArray, '総数');// 左端は総数のカラムを追加 | |
318 | - $xTitleCount = count($xTitleArray); | |
228 | + array_unshift($this->xTitleArray, '総数');// 左端は総数のカラムを追加 | |
229 | + $xTitleCount = count($this->xTitleArray); | |
319 | 230 | for ($i = 0; $i < $xTitleCount; $i++){ |
320 | 231 | $row = array( |
321 | - 'date' => $this->convertToDispString($xTitleArray[$i]) // X軸タイトル | |
232 | + 'date' => $this->convertToDispString($this->xTitleArray[$i]) // X軸タイトル | |
322 | 233 | ); |
323 | 234 | $this->tmpl->addVars('datelist', $row); |
324 | 235 | $this->tmpl->parseTemplate('datelist', 'a'); |
@@ -335,6 +246,7 @@ class admin_blog_mainAnalyticsWidgetContainer extends admin_blog_mainBaseWidgetC | ||
335 | 246 | $this->tmpl->addVar('_widget', 'end_date', $this->convertToDispDate($this->endDate)); // 集計期間(終了) |
336 | 247 | $this->tmpl->addVar('draw_graph', 'x_ticks', $graphDataXStr); // グラフX軸タイトル |
337 | 248 | $this->tmpl->addVar('draw_graph', 'y_values', $graphDataYStr); // グラフY軸値 |
249 | + $this->tmpl->addVar('draw_graph', 'keys', $graphDataKeyStr); // グラフデータキー | |
338 | 250 | $this->tmpl->addVar('draw_graph', 'y_max', $yMax); // グラフY座標最大値 |
339 | 251 | } |
340 | 252 | /** |
@@ -531,5 +443,109 @@ class admin_blog_mainAnalyticsWidgetContainer extends admin_blog_mainBaseWidgetC | ||
531 | 443 | } |
532 | 444 | return $viewData; |
533 | 445 | } |
446 | + /** | |
447 | + * グラフ用データ作成 | |
448 | + * | |
449 | + * @return なし | |
450 | + */ | |
451 | + function createGraphData() | |
452 | + { | |
453 | + // ##### 集計グラフ作成 ##### | |
454 | + $this->xTitleArray = array(); | |
455 | + $this->yValueArray = array(); | |
456 | + $this->graphDataKeyArray = array(); // グラフデータ取得用キー | |
457 | + | |
458 | + // 集計グラフ用データ取得 | |
459 | + if ($this->calcType == 'day'){ // 日単位で集計の場合 | |
460 | + $this->db->getAllContentViewCountByDate(blog_mainCommonDef::VIEW_CONTENT_TYPE, $this->startDate, $this->endDate, array($this, 'contentViewCountLoop')); | |
461 | + | |
462 | + // X軸ラベル作成 | |
463 | + $dateTimestamp = strtotime($this->startDate); | |
464 | + $startTimestamp = $dateTimestamp; | |
465 | + $endTimestamp = strtotime($this->endDate); | |
466 | + $date = $this->startDate; | |
467 | + $graphDataKey = date($this->graphDataKeyFormat, $dateTimestamp); | |
468 | + while (true){ | |
469 | + if ($dateTimestamp > $endTimestamp) break; | |
470 | + $this->graphDataKeyArray[] = $graphDataKey; // グラフデータ取得用キー | |
471 | + | |
472 | + // グラフ用のデータ作成 | |
473 | + $this->xTitleArray[] = date('n/j', $dateTimestamp); // X軸タイトル。表示フォーマットに変換。 | |
474 | + $value = $this->graphDataArray[$graphDataKey]; | |
475 | + if (isset($value)){ | |
476 | + $this->yValueArray[] = intval($value); | |
477 | + } else { | |
478 | + $this->yValueArray[] = 0; | |
479 | + } | |
480 | + $dateTimestamp = strtotime("$date 1 day"); | |
481 | + $date = date(self::DATE_FORMAT, $dateTimestamp); // 次の日に更新 | |
482 | + $graphDataKey = date($this->graphDataKeyFormat, $dateTimestamp); | |
483 | + } | |
484 | + | |
485 | + $this->tmpl->setAttribute('graph_clickable', 'visibility', 'visible'); // 1日分のグラフ画面への遷移を可能にする | |
486 | + } else if ($this->calcType == 'month'){ // 月単位で集計の場合 | |
487 | + $this->db->getAllContentViewCountByMonth(blog_mainCommonDef::VIEW_CONTENT_TYPE, $this->startDate, $this->endDate, array($this, 'contentViewCountLoop')); | |
488 | + | |
489 | + // X軸ラベル作成 | |
490 | + $year = $startYear; | |
491 | + $month = $startMonth; | |
492 | + $dateTimestamp = strtotime("$year-$month-1"); | |
493 | + $graphDataKey = date($this->graphDataKeyFormat, $dateTimestamp); | |
494 | + | |
495 | + for ($i = 0; $i < 12; $i++){ | |
496 | + $this->graphDataKeyArray[] = $graphDataKey; // グラフデータ取得用キー | |
497 | + | |
498 | + // グラフ用のデータ作成 | |
499 | + $this->xTitleArray[] = date('n月', $dateTimestamp); // X軸タイトル。表示フォーマットに変換。 | |
500 | + $value = $this->graphDataArray[$graphDataKey]; | |
501 | + if (isset($value)){ | |
502 | + $this->yValueArray[] = intval($value); | |
503 | + } else { | |
504 | + $this->yValueArray[] = 0; | |
505 | + } | |
506 | + | |
507 | + // 次の月へ進む | |
508 | + $month++; | |
509 | + if ($month > 12){ | |
510 | + $month = 1; | |
511 | + $year++; | |
512 | + } | |
513 | + $dateTimestamp = strtotime("$year-$month-1"); | |
514 | + $graphDataKey = date($this->graphDataKeyFormat, $dateTimestamp); | |
515 | + } | |
516 | + } else if ($this->calcType == 'hour'){ // 時間単位で集計の場合 | |
517 | + $this->db->getAllContentViewCountByHour(blog_mainCommonDef::VIEW_CONTENT_TYPE, $this->startDate, $this->endDate, array($this, 'contentViewCountLoop')); | |
518 | + | |
519 | + // X軸ラベル作成 | |
520 | + for ($i = 0; $i < 24; $i++){ | |
521 | + $this->graphDataKeyArray[] = $i; // グラフデータ取得用キー | |
522 | + | |
523 | + // グラフ用のデータ作成 | |
524 | + $this->xTitleArray[] = $i . '時'; // X軸タイトル(時間) | |
525 | + $value = $this->graphDataArray[$i]; | |
526 | + if (isset($value)){ | |
527 | + $this->yValueArray[] = intval($value); | |
528 | + } else { | |
529 | + $this->yValueArray[] = 0; | |
530 | + } | |
531 | + } | |
532 | + } else if ($this->calcType == 'week'){ // 曜日単位で集計の場合 | |
533 | + $this->db->getAllContentViewCountByWeek(blog_mainCommonDef::VIEW_CONTENT_TYPE, $this->startDate, $this->endDate, array($this, 'contentViewCountLoop')); | |
534 | + | |
535 | + // X軸ラベル作成 | |
536 | + for ($i = 0; $i < 7; $i++){ | |
537 | + $this->graphDataKeyArray[] = $i; // グラフデータ取得用キー | |
538 | + | |
539 | + // グラフ用のデータ作成 | |
540 | + $this->xTitleArray[] = $this->weekTypeArray[$i]; // X軸タイトル(曜日) | |
541 | + $value = $this->graphDataArray[$i]; | |
542 | + if (isset($value)){ | |
543 | + $this->yValueArray[] = intval($value); | |
544 | + } else { | |
545 | + $this->yValueArray[] = 0; | |
546 | + } | |
547 | + } | |
548 | + } | |
549 | + } | |
534 | 550 | } |
535 | 551 | ?> |
@@ -11,7 +11,6 @@ | ||
11 | 11 | * @link http://www.magic3.org |
12 | 12 | */ |
13 | 13 | <patTemplate:tmpl name="_widget"> |
14 | -<!--<script type="text/javascript" src="{_SCRIPTS_URL}/{LIB_DIR}/plugins/jqplot.dateAxisRenderer.min.js"></script>--> | |
15 | 14 | <script type="text/javascript" src="{_SCRIPTS_URL}/{LIB_DIR}/plugins/jqplot.categoryAxisRenderer.min.js"></script> |
16 | 15 | <script type="text/javascript" src="{_SCRIPTS_URL}/{LIB_DIR}/plugins/jqplot.barRenderer.js"></script> |
17 | 16 | <script type="text/javascript" src="{_SCRIPTS_URL}/{LIB_DIR}/plugins/jqplot.highlighter.js"></script> |
@@ -23,15 +22,13 @@ function changeCalcType(){ | ||
23 | 22 | return true; |
24 | 23 | } |
25 | 24 | $(function(){ |
26 | - // テーブルを作成 | |
27 | -// m3SetConfigTable('mainconfig'); | |
28 | - | |
29 | 25 | <patTemplate:tmpl name="draw_graph"> |
30 | 26 | // アクセス数グラフ作成 |
31 | 27 | var values = {Y_VALUES}; |
32 | 28 | var ticks = {X_TICKS}; |
29 | + var keys = {KEYS}; | |
33 | 30 | |
34 | - plot1 = $.jqplot('chart1', [values], { | |
31 | + $.jqplot('chart1', [values], { | |
35 | 32 | animate: !$.jqplot.use_excanvas, |
36 | 33 | seriesDefaults:{ |
37 | 34 | renderer:$.jqplot.BarRenderer, |
@@ -59,11 +56,22 @@ $(function(){ | ||
59 | 56 | formatString: '%s' |
60 | 57 | } |
61 | 58 | }); |
59 | +<patTemplate:tmpl name="graph_clickable" visibility="hidden"> | |
60 | + $("#chart1 .jqplot-xaxis-tick").css({ | |
61 | + cursor: "pointer", | |
62 | + zIndex: "1" | |
63 | + }).click(function(){ | |
64 | + var index = $('#chart1 .jqplot-xaxis-tick').index(this); | |
65 | +// alert('項目番号:' +index); | |
66 | + alert(keys[index]); | |
67 | + // 画面遷移 | |
68 | + //location.href = "http://google.com"; | |
69 | + }); | |
70 | +</patTemplate:tmpl> | |
62 | 71 | </patTemplate:tmpl> |
63 | 72 | |
64 | 73 | // 上位アクセスコンテンツテーブル |
65 | 74 | $('#mainconfig').m3stickyheader(); |
66 | - | |
67 | 75 | }); |
68 | 76 | //]]> |
69 | 77 | </script> |