All Downloads are FREE. Search and download functionalities are using the official Maven repository.

META-INF.resources.chart.other.jspf Maven / Gradle / Ivy

The newest version!
<%--
/**
 * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
 *
 * This library is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation; either version 2.1 of the License, or (at your option)
 * any later version.
 *
 * This library is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
 * details.
 */
--%>

<%
SocialActivityCounter highestActivityCounter = null;
SocialActivityCounter lowestActivityCounter = null;

int[] categories = new int[activityCounters.size()];
int[] values = new int[activityCounters.size()];

int currentValue = 0;
int totalValue = 0;

int totalDays = 0;

for (int i = 0; i < activityCounters.size(); i++) {
	SocialActivityCounter activityCounter = activityCounters.get(i);

	if ((highestActivityCounter == null) || (highestActivityCounter.getCurrentValue() < activityCounter.getCurrentValue())) {
		highestActivityCounter = activityCounter;
	}

	if ((lowestActivityCounter == null) || (lowestActivityCounter.getCurrentValue() > activityCounter.getCurrentValue())) {
		lowestActivityCounter = activityCounter;
	}

	categories[i] = i + 1;
	values[i] = activityCounter.getCurrentValue();

	totalValue = totalValue + activityCounter.getCurrentValue();

	if (activityCounter.getEndPeriod() == -1) {
		currentValue = activityCounter.getCurrentValue();

		totalDays = totalDays + SocialCounterPeriodUtil.getActivityDay() - activityCounter.getStartPeriod() + 1;
	}
	else {
		totalDays = totalDays + activityCounter.getEndPeriod() - activityCounter.getStartPeriod() + 1;
	}
}

Format format = FastDateFormatFactoryUtil.getSimpleDateFormat("MMM d");
%>


	
		
: <%= currentValue %>
: <%= Math.round(totalValue / totalDays * 100) / 100 %>
: <%= format.format(SocialCounterPeriodUtil.getDate(highestActivityCounter.getStartPeriod())) %> - <%= format.format(SocialCounterPeriodUtil.getDate(highestActivityCounter.getEndPeriod())) %> <%= format.format(new Date()) %> (<%= highestActivityCounter.getCurrentValue() %>)
: <%= format.format(SocialCounterPeriodUtil.getDate(lowestActivityCounter.getStartPeriod())) %> - <%= format.format(SocialCounterPeriodUtil.getDate(lowestActivityCounter.getEndPeriod())) %> <%= format.format(new Date()) %> (<%= lowestActivityCounter.getCurrentValue() %>)
var categories = [<%= StringUtil.merge(categories) %>]; var values = [<%= StringUtil.merge(values) %>]; var data = []; for (var i = 0; i < categories.length; i++) { data.push({ category: categories[i], values: values[i], }); } var tooltip = { markerLabelFunction: function ( categoryItem, valueItem, itemIndex, series, seriesIndex ) { return valueItem.value; }, styles: { backgroundColor: '#FFF', borderColor: '#4572A7', borderWidth: 1, color: '#000', textAlign: 'center', width: 30, }, }; var chartType; var customConfig; chartType = 'combo'; customConfig = { showAreaFill: true, showMarkers: true, styles: { series: { values: { area: { alpha: 0.4, color: '#5CC0FF', }, line: { color: '#4572A7', weight: 2, }, marker: { fill: { color: '#3CCFFF', }, height: 6, }, }, }, }, }; chartType = '<%= HtmlUtil.escapeJS(chartType) %>'; customConfig = { showAreaFill: true, showMarkers: true, }; var chartContainer = A.one( '#groupStatisticsChart<%= displayActivityCounterNameIndex %>' ); var defaultConfig = { axes: { category: { styles: { label: { display: 'none', }, }, }, values: { styles: { majorUnit: { count: 6, }, }, }, }, dataProvider: data, height: <%= displayHeight - 2 %>, horizontalGridlines: true, tooltip: tooltip, type: chartType, width: chartContainer.width(), }; A.mix(defaultConfig, customConfig); var chart = new A.Chart(defaultConfig).render(chartContainer); Liferay.after(['portletMoved', 'liferaypanel:collapse'], function (event) { var width = chartContainer.width(); if ( (width && event.type == 'portletMoved' && event.portletId == '<%= portletDisplay.getId() %>') || (event.type == 'liferaypanel:collapse' && event.panelId == 'groupStatisticsPanel<%= displayActivityCounterNameIndex %>') ) { chart.set('width', width); } });




© 2015 - 2024 Weber Informatics LLC | Privacy Policy