riot.tag2('qualva-cv', '
{parent.completeCount}/{parent.totalCount}
{compareInfo.option.label}{(parent.completeCount / parent.totalCount * 100).toFixed(1)}%
{parent.compareCompleteCount}/{parent.compareTotalCount}
{compareInfo.option.compareLabel}{(parent.compareCompleteCount / parent.compareTotalCount * 100).toFixed(1)}%
', 'qualva-cv,[riot-tag="qualva-cv"],[data-is="qualva-cv"]{ display: block }', 'class="number"', function(opts) { this.chartColors = this.opts.option.chartColors || (this.opts.option.themeColor ? window.colors[this.opts.option.themeColor] : void 0) || (window.view.setting.themeColor ? window.colors[window.view.setting.themeColor] : void 0) || window.colors['qualva-cv']; this.totalCount = 0; this.completeCount = 0; this.compareTotalCount = 0; this.compareCompleteCount = 0; this.on('mount', (function(_this) { return function() {}; })(this)); this.on('unmount', (function(_this) { return function() {}; })(this)); this.init = (function(_this) { return function() { return _this.reload(); }; })(this); this.reload = (function(_this) { return function() { if (_this.tags.content.isCompare()) { return _this.compareChanged(); } else { return _this.getData(); } }; })(this); this.compareChanged = (function(_this) { return function() { var compareCondition, condition, filter; filter = _this.tags.content.getConditionFilter(_this.opts.option.filter); condition = { selectAs: _this.opts.option.selectAs, term: window.condition.term, filter: filter }; compareCondition = _this.tags.content.getCompareCondition(condition); return $.when.apply(null, [ Resources.post({ uri: "/summary/gt", data: { projectId: _this.opts.option.projectId || window.project.id, summaryColumn: { column: "inputDate", type: "datetime" }, crossColumns: [_this.opts.option.summaryColumn], condition: condition } }), Resources.post({ uri: "/summary/gt", data: { projectId: _this.opts.option.projectId || window.project.id, summaryColumn: { column: "inputDate", type: "datetime" }, crossColumns: [_this.opts.option.summaryColumn], condition: compareCondition } }) ]).then(function(results) { var datas, gts, total; gts = _.map(arguments, 0); _.each(gts[0].summary, function(data, i) { var comp; if (gts[1].summary[i]) { comp = gts[1].summary[i].cross1; } else { comp = 0; } data.compare = comp; if (gts[1].total.count > 0) { return data.comparePercent = comp / gts[1].total.cross1 * 100; } else { return data.comparePercent = 0; } }); total = gts[0].total; datas = gts[0].summary; _this.totalCount = total.count; _this.completeCount = total != null ? total.cross1 : void 0; total = gts[1].total; datas = gts[1].summary; _this.compareTotalCount = total.count; _this.compareCompleteCount = total != null ? total.cross1 : void 0; _this.drawChart(gts[0]); return _this.update(); }); }; })(this); this.getData = (function(_this) { return function() { var filter; filter = _this.tags.content.getConditionFilter(_this.opts.option.filter); return Resources.post({ uri: "/summary/gt", data: { projectId: _this.opts.option.projectId || window.project.id, summaryColumn: { column: "inputDate", type: "datetime" }, crossColumns: [_this.opts.option.summaryColumn], condition: { selectAs: _this.opts.option.selectAs, term: window.condition.term, filter: filter } } }).then(function(gt) { var datas, total, valueListInfo; valueListInfo = gt.valueListInfo; total = gt.total; datas = gt.summary; _this.totalCount = total.count; _this.completeCount = total.cross1; _this.drawChart(gt); return _this.update(); }); }; })(this); this.summaryColumnLabel = (function(_this) { return function(column) { var col; col = _.find(window.columns, function(col) { return (col.columnName.indexOf(column)) !== -1; }); return col.displayLabel; }; })(this); this.drawChart = (function(_this) { return function(gt) { var chartConfig, dataProvider, datas, from, graphs, isInDay, lines, to, total, totalCount, valueListInfo; valueListInfo = gt.valueListInfo; total = gt.total; datas = gt.summary; if (_this.opts.option.inverse) { datas.reverse(); } totalCount = total.count; dataProvider = datas; lines = [ { field: 'cross1', title: 'CV数' } ]; graphs = _.map(lines, function(line, i) { var color, graph, title, valueField; color = _this.chartColors[i % _this.chartColors.length]; title = line.title; valueField = line.field; return graph = { bullet: "round", bulletColor: color, bulletSize: 10, bulletBorderAlpha: 0, bulletAlpha: 0, hideBulletsCount: 0, lineThickness: 1, useLineColorForBulletBorder: true, showBalloon: false, fillAlphas: 0.1, lineAlpha: 0.5, title: title, fillColors: color, lineColor: color, valueField: valueField, type: _this.opts.option.graphType || "smoothedLine" }; }); chartConfig = { type: 'serial', theme: 'none', percentPrecision: 1, precision: 1, dataProvider: dataProvider, valueAxes: [ { stackType: 'none', axisAlpha: 0.0, axisColor: '#ccc', gridAlpha: 0.0, gridColor: '#ccc', color: "#666", labelsEnabled: false, minHorizontalGap: 20, tickLength: 0, gridCount: 10 } ], pathToImages: "http://cdn.amcharts.com/lib/3/images/", graphs: graphs, categoryField: 'inputDate', categoryAxis: { startOnAxis: true, equalSpacing: true, parseDates: true, dashLength: 0, gridAlpha: 0, minorGridAlpha: 0, tickLength: 0, axisAlpha: 0.0, labelsEnabled: false, minorGridEnabled: false }, fontSize: 10, exportConfig: { hideButton: true } }; from = moment(window.condition.term.fromDate); to = moment(window.condition.term.toDate); isInDay = to.diff(from, 'days') <= 1; if (isInDay) { chartConfig.dataDateFormat = "YYYY-MM-DD HH:NN"; chartConfig.categoryAxis.minPeriod = 'hh'; chartConfig.categoryAxis.dateFormats = [ { period: 'hh', format: 'HH:NN' }, { period: 'DD', format: 'MM/DD' }, { period: 'WW', format: 'MM' }, { period: 'MM', format: 'YYYYMM' }, { period: 'YYYY', format: 'YYYY/MM' } ]; } else { chartConfig.dataDateFormat = "YYYY-MM-DD"; chartConfig.categoryAxis.minPeriod = 'DD'; chartConfig.categoryAxis.dateFormats = [ { period: 'DD', format: 'MM/DD' }, { period: 'WW', format: 'MM' }, { period: 'MM', format: 'YYYY/MM' }, { period: 'YYYY', format: 'YYYY/MM' } ]; } AmCharts.makeChart("chart_" + _this.opts.id, chartConfig); _this.update(); return _this.loadComplete(); }; })(this); this.loadComplete = (function(_this) { return function() { return _this.tags.content.loadComplete(); }; })(this); });