<commit_before>/*
 * Copyright (c) 2002-2010 "Neo Technology,"
 * Network Engine for Objects in Lund AB [http://neotechnology.com]
 *
 * This file is part of Neo4j.
 *
 * Neo4j is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 *
 * This program 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 Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 */


wa.components.dashboard.monitorChartCounter = 0;

/**
 * A chart that shows data from one or more monitor data sources over time. The
 * data is acquired via the morpheus.monitor.update event, which is
 * triggered for each loaded server at regular intervals.
 * 
 * Available settings include:
 * 
 * <ul>
 * <li>label : the label for the module that the graph is shown in</li>
 * <li>height : integer value, height in pixels of the chart, default is 200</li>
 * <li>data : an object with data source definitions. Each key in this object
 * should correspond to a data set key used by the rrdb monitor system. See
 * {@link org.neo4j.server.webadmin.rrd.RrdManager}. For available settings in each
 * data set, see below</li>
 * </ul>
 * 
 * Data sources have the following settings:
 * 
 * <ul>
 * <li>label : is the label to show in the legend</li>
 * </ul>
 * 
 * @param server
 *            is the server to work with
 * @param settings
 *            is an object that specifies what data to show and how. See above
 *            for available settings.
 */
wa.components.dashboard.MonitorChart = function(server, settings) {
	
	var me = {};
	
	// Default settings
	me.settings = {
		label : "",
		xaxis : {
			mode: "time",
		    timeformat: "%H:%M:%S"
		},
		yaxis : { },
		height : 200,
		data : [],
		series : {
			
		},
		tooltipValueFormatter : function(v) {return v;},
		colors : ["#326a75","#4f848f","#a0c2c8","#00191e"]
	};
	
	// Override defaults with user settings
	var settings = settings || {};
	$.extend( true, me.settings, settings );
	
	// Define data series
	me.series = [];
	for( var key in me.settings.data ) {
		me.settings.data[key].key = key;
		me.series.push(me.settings.data[key]);
	}
	
	me.server = server;
	me.containerId = "mor_monitor_chart_" + wa.components.dashboard.monitorChartCounter++;
	me.controlsClass = me.containerId + "_controls";
	me.zoom = {
		year : { 
			id : me.containerId + "_zoom_0",
			xSpan : 1000 * 60 * 60 * 24 * 365,
		    timeformat: "%d/%m %y"
		},
		month : { 
			id : me.containerId + "_zoom_1",
			xSpan : 1000 * 60 * 60 * 24 * 30,
		    timeformat: "%d/%m"
		},
		week : { 
			id : me.containerId + "_zoom_2",
			xSpan : 1000 * 60 * 60 * 24 * 7,
		    timeformat: "%d/%m"
		},
		day : { 
			id : me.containerId + "_zoom_3",
			xSpan : 1000 * 60 * 60 * 24,
		    timeformat: "%H:%M"
		},
		six_hours : { 
			id : me.containerId + "_zoom_4",
			xSpan : 1000 * 60 * 60 * 6,
		    timeformat: "%H:%M"
		},
		thirty_minutes : { 
			id : me.containerId + "_zoom_5",
			xSpan : 1000 * 60 * 30,
		    timeformat: "%H:%M"
		}
	};
	
	// TODO: Move this into a template
	var controls = "<ul class='mor_module_actions'>";
	controls += "<li><a class='"+me.controlsClass+"' href='#' id='"+me.zoom.year.id +"'>Year</a></li>";
	controls += "<li><a class='"+me.controlsClass+"' href='#' id='"+me.zoom.month.id +"'>Month</a></li>";
	controls += "<li><a class='"+me.controlsClass+"' href='#' id='"+me.zoom.week.id +"'>Week</a></li>";
	controls += "<li class='current'><a class='"+me.controlsClass+"' href='#' id='"+me.zoom.day.id +"'>Day</a></li>";
	controls += "<li><a class='"+me.controlsClass+"' href='#' id='"+me.zoom.six_hours.id +"'>6 hours</a></li>";
	controls += "<li><a class='"+me.controlsClass+"' href='#' id='"+me.zoom.thirty_minutes.id +"'>30 minutes</a></li>";
	controls += "</ul><div class='break'></div>";
	
	me.container = $("<div>" + controls + "<div class='mor_chart_container'><div style='height:"+me.settings.height+"px;' id='" + me.containerId + "'></div></div></div>");
	
	me.drawing = false;
	me.currentZoom = "day";
	me.currentData = [];
	
	me.api = {
		
		render : function() {<commit_msg>Made 30minutes the default view in charts.<commit_after>/*
 * Copyright (c) 2002-2010 "<NAME>,"
 * Network Engine for Objects in Lund AB [http://neotechnology.com]
 *
 * This file is part of Neo4j.
 *
 * Neo4j is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 *
 * This program 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 Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 */


wa.components.dashboard.monitorChartCounter = 0;

/**
 * A chart that shows data from one or more monitor data sources over time. The
 * data is acquired via the morpheus.monitor.update event, which is
 * triggered for each loaded server at regular intervals.
 * 
 * Available settings include:
 * 
 * <ul>
 * <li>label : the label for the module that the graph is shown in</li>
 * <li>height : integer value, height in pixels of the chart, default is 200</li>
 * <li>data : an object with data source definitions. Each key in this object
 * should correspond to a data set key used by the rrdb monitor system. See
 * {@link org.neo4j.server.webadmin.rrd.RrdManager}. For available settings in each
 * data set, see below</li>
 * </ul>
 * 
 * Data sources have the following settings:
 * 
 * <ul>
 * <li>label : is the label to show in the legend</li>
 * </ul>
 * 
 * @param server
 *            is the server to work with
 * @param settings
 *            is an object that specifies what data to show and how. See above
 *            for available settings.
 */
wa.components.dashboard.MonitorChart = function(server, settings) {
	
	var me = {};
	
	// Default settings
	me.settings = {
		label : "",
		xaxis : {
			mode: "time",
		    timeformat: "%H:%M:%S"
		},
		yaxis : { },
		height : 200,
		data : [],
		series : {
			
		},
		tooltipValueFormatter : function(v) {return v;},
		colors : ["#326a75","#4f848f","#a0c2c8","#00191e"]
	};
	
	// Override defaults with user settings
	var settings = settings || {};
	$.extend( true, me.settings, settings );
	
	// Define data series
	me.series = [];
	for( var key in me.settings.data ) {
		me.settings.data[key].key = key;
		me.series.push(me.settings.data[key]);
	}
	
	me.server = server;
	me.containerId = "mor_monitor_chart_" + wa.components.dashboard.monitorChartCounter++;
	me.controlsClass = me.containerId + "_controls";
	me.zoom = {
		year : { 
			id : me.containerId + "_zoom_0",
			xSpan : 1000 * 60 * 60 * 24 * 365,
		    timeformat: "%d/%m %y"
		},
		month : { 
			id : me.containerId + "_zoom_1",
			xSpan : 1000 * 60 * 60 * 24 * 30,
		    timeformat: "%d/%m"
		},
		week : { 
			id : me.containerId + "_zoom_2",
			xSpan : 1000 * 60 * 60 * 24 * 7,
		    timeformat: "%d/%m"
		},
		day : { 
			id : me.containerId + "_zoom_3",
			xSpan : 1000 * 60 * 60 * 24,
		    timeformat: "%H:%M"
		},
		six_hours : { 
			id : me.containerId + "_zoom_4",
			xSpan : 1000 * 60 * 60 * 6,
		    timeformat: "%H:%M"
		},
		thirty_minutes : { 
			id : me.containerId + "_zoom_5",
			xSpan : 1000 * 60 * 30,
		    timeformat: "%H:%M"
		}
	};
	
	// TODO: Move this into a template
	var controls = "<ul class='mor_module_actions'>";
	controls += "<li><a class='"+me.controlsClass+"' href='#' id='"+me.zoom.year.id +"'>Year</a></li>";
	controls += "<li><a class='"+me.controlsClass+"' href='#' id='"+me.zoom.month.id +"'>Month</a></li>";
	controls += "<li><a class='"+me.controlsClass+"' href='#' id='"+me.zoom.week.id +"'>Week</a></li>";
	controls += "<li><a class='"+me.controlsClass+"' href='#' id='"+me.zoom.day.id +"'>Day</a></li>";
	controls += "<li><a class='"+me.controlsClass+"' href='#' id='"+me.zoom.six_hours.id +"'>6 hours</a></li>";
	controls += "<li class='current'><a class='"+me.controlsClass+"' href='#' id='"+me.zoom.thirty_minutes.id +"'>30 minutes</a></li>";
	controls += "</ul><div class='break'></div>";
	
	me.container = $("<div>" + controls + "<div class='mor_chart_container'><div style='height:"+me.settings.height+"px;' id='" + me.containerId + "'></div></div></div>");
	
	me.drawing = false;
	me.currentZoom = "thirty_minutes";
	me.currentData = [];
	
	me.api = {
		
		render : function() {
{'fraction_non_alphanumeric': 0.16759094942324756, 'fraction_numerical': 0.024179236912156166, 'mean_word_length': 3.299952312827849, 'pattern_counts': {'":': 0, '<': 98, '<?xml version=': 0, '>': 98, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5277743', 'n_tokens_mistral': 3347, 'n_tokens_neox': 2945, 'n_words': 925}