PageSourceSearch

https://www.carms.ca/wp-content/themes/jupiter-child/assets/js/chart.js

js carms.ca collected 2026-10-02 03:22:31 UTC 6,608 bytes, 253 lines download raw bytes

1var discipline_data;
2var rollup_data;
3var lang;
4
5// Load Google charts and table packages
6google.charts.load('current', {
7	packages: ['corechart', 'table']
8});
9
10//Discipline list options object for English values
11var discipline_en;
12var discipline_fr;
13
14//google data table columns in English
15var data_table_en = [{
16	year: ['Year', 'string'],
17	quota: ['Quota', 'number'],
18	field: ['Filled', 'number'],
19	topChoice: ['Ranked discipline as 1st choice', 'number'],
20	applicants: ['Applicants', 'number']
21
22
23}];
24
25//google data table columns in french
26var data_table_fr = [{
27	year: ['Année', 'string'],
28	quota: ['Quota', 'number'],
29	field: ['Pourvu', 'number'],
30	topChoice: ['Discipline classée comme premier choix', 'number'],
31	applicants: ['Candidatures', 'number']
32}];
33
34var data_file = '';
35// Set chart options
36var chartOptions = {
37	title: '',
38	tooltip: {
39		trigger: {isHtml: true}
40	},
41	animation:{
42		startup:true,
43		duration: 800,
44		easing: 'inAndOut',
45	},
46	vAxis: {
47		title: '',
48	},
49	hAxis: {
50		title: '',
51		format: '####',
52	},
53	seriesType: 'bars',
54	series: {
55		0: {
56			type: 'bars',
57			color: '#5B325E'
58		},
59		1: {
60			type: 'bars',
61			color: '#5D97AB'
62		},
63		2: {
64			type: 'line',
65			color: '#FFC30E'
66		},
67		3: {
68			type: 'line',
69			color: '#72BF44'
70		}
71	},
72	chartArea: {
73		left:80,
74		height: '75%',
75		width:'100%'
76	},
77	legend:{
78		position:'bottom',
79		alignment:'center'
80	},
81};
82
83//set table options
84var tableOptions = {
85	showRowNumber: false,
86	height: '100%',
87	width:'100%'
88};
89
90//Get URL value to find what data to select
91var url = jQuery(location).attr('href');
92
93//Using this list to handle translation for discipline group and list values
94var isFrench;
95var discipline_list = [];
96var data_table = [];
97
98if (url.indexOf("/fr/") > 0) {
99    isFrench = true;
100    data_table = data_table_fr;
101    data_file = 'data.fr.json';
102    chartOptions.title = "Données nationales concernant les candidatures et les quotas des DCM par discipline pendant le jumelage R-1 (2008-2019, 1er tour seulement)";
103    chartOptions.vAxis.title = "TOTAL";
104} else {
105    isFrench = false;
106    data_table = data_table_en;
107    data_file = 'data.en.json';
108    chartOptions.title = "National Data on CMG Applicants & Quota in the R-1 Match by Disciplines (2008 - 2019, 1st Iteration Only)";
109    chartOptions.vAxis.title = "SUM";
110}
111
112function getDisciplineHeadings(discipline_data) {
113
114	discipline = [
115		{
116			'non_surgical': []
117		},
118		{
119			'surgical': []
120		}
121	]
122
123	for (var i = 0; i < discipline_data.length; i++) {
124		whichArray = 0;
125		if (discipline_data[i].discipline_group == 'surgical') {
126            whichArray = 1;
127        }
128
129        if (discipline[whichArray][discipline_data[i].discipline_group].indexOf(discipline_data[i].discipline) === -1) {
130            discipline[whichArray][discipline_data[i].discipline_group].push(discipline_data[i].discipline);
131		}
132
133	}
134
135	// sort the arrays
136    discipline[0]['non_surgical'].sort();
137	discipline[1]['surgical'].sort();
138
139	discipline[0]['non_surgical'].splice(0, 0, 'non_surgical');
140    discipline[1]['surgical'].splice(0, 0, 'surgical');
141
142    discipline_list = discipline;
143
144    // at this point...move ahead with the rest of the page functions...
145    selectionChange('All Disciplines', isFrench ? 'Toutes les disciplines' : 'All Disciplines');
146}
147
148//This is event listener for document onLoad
149google.charts.setOnLoadCallback(function() {
150
151	lang = 'en';
152	if (isFrench) lang = 'fr';
153
154	// fetch the data files we need to populate charts and graphs
155	jQuery.getJSON('/wp-content/themes/jupiter-child/assets/data/data.' + lang + '.json', function(data) {
156		discipline_data = data.disciplines;
157		jQuery.getJSON('/wp-content/themes/jupiter-child/assets/data/data.rollup.' + lang + '.json', function(data) {
158			rollup_data = data.totals;
159
160			getDisciplineHeadings(discipline_data);
161
162		});
163	});
164
165
166});
167
168//This function handles all selection changes
169var selectionChange = function(selection, displayName) {
170	var discipline_option = jQuery("#discipline_option"); //Dropdown list for Discipline list
171	discipline_option.empty(); //Remove all options before populating new option
172	drawChart(selection); //Re-render chart for every new selection
173	if (selection === "All Disciplines") {
174		discipline_option.attr('disabled', 'disabled');
175		discipline_option.append(new Option(displayName, selection));
176	} else {
177		jQuery.each(discipline_list, function(index, value) {
178			//On selection surgical
179			if (selection === 'surgical' || selection === "chirurgicales") {
180				discipline_option.removeAttr('disabled');
181				jQuery.each(value[selection], function(index, option) {
182					if(option === selection){
183						discipline_option.append(new Option(displayName, option));
184					}
185					else {
186						discipline_option.append(new Option(option, option));
187					}
188				});
189			}
190			//On selection non surgical
191			if (selection === 'non_surgical' || selection === "non_chirurgicales") {
192				discipline_option.removeAttr('disabled');
193				jQuery.each(value[selection], function(index, option) {
194					if(option === selection){
195						discipline_option.append(new Option(displayName, option));
196					}
197					else {
198						discipline_option.append(new Option(option, option));
199					}
200				});
201			}
202		});
203	}
204};
205
206//This function draws google chart and table according to provided option
207var drawChart = function(selection) {
208	// Define the chart to be drawn.
209	var google_table = new google.visualization.DataTable();
210	//Add Column values to data table
211	jQuery.each(data_table, function(index, value) {
212		jQuery.each(value, function(idex, value) {
213			google_table.addColumn(value[1], value[0]);
214		});
215	});
216
217	var live_data = discipline_data;
218	var comparison_property = 'discipline';
219	if (selection === 'All Disciplines' || selection === 'surgical' || selection === 'non_surgical' || selection === 'chirurgicales' || selection === 'non_chirurgicales') {
220		live_data = rollup_data;
221		comparison_property = 'discipline_group';
222	}
223
224
225	jQuery.each(live_data, function(index, value) {
226
227		if (value[comparison_property] === selection) {
228			google_table.addRow(
229				[String(value.year),
230					value.quota,
231					value.filled,
232					value.top_choice,
233					value.applicants
234
235				]
236			);
237		}
238	});
239
240	//if silection is discipline option
241
242	// Instantiate and draw the chart.
243	if( jQuery('#chart_render').length > 0 ){
244		var chart = new google.visualization.ComboChart(document.getElementById('chart_render'));
245		chart.draw(google_table, chartOptions);
246	}
247	//Instantiate and draw the table
248	if( jQuery('#table_render').length > 0 ){
249		var table = new google.visualization.Table(document.getElementById('table_render'));
250		table.draw(google_table, tableOptions);
251	}
252
253};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.