From 4d6115ed95162c92218fd1a4a679d31e017b6863 Mon Sep 17 00:00:00 2001 From: mike seibel Date: Mon, 23 Dec 2024 13:23:30 -0800 Subject: [PATCH] chart container cleanup --- .../static/coursedashboards/js/course.js | 8 ++-- .../static/coursedashboards/js/graphs.js | 1 - .../static/coursedashboards/js/historic.js | 41 +++++++++++++++---- 3 files changed, 37 insertions(+), 13 deletions(-) diff --git a/coursedashboards/static/coursedashboards/js/course.js b/coursedashboards/static/coursedashboards/js/course.js index e9185cac..ea97a401 100644 --- a/coursedashboards/static/coursedashboards/js/course.js +++ b/coursedashboards/static/coursedashboards/js/course.js @@ -25,7 +25,8 @@ var showCourseData = function (label) { terms = [], current_course_panel = (compare_terms(section.year, section.quarter, window.term.year, window.term.quarter) >= 0), - performanceTemplate; + performanceTemplate, + chart_container; if (!current_course_panel && !section.loaded) { fetchCourseData(label); @@ -60,8 +61,6 @@ var showCourseData = function (label) { display_course: section.display_course })); - renderCoursePercentage1('current-declared-majors-chart', section.current_student_majors, 'major_name', 'percent_students'); - renderCoursePercentage1('current-concurrent-courses-chart', section.concurrent_courses, 'course_ref', 'percent_students'); if (current_course_panel) { var registered_percent = (section.current_enrollment / section.limit_estimate_enrollment) * 100, @@ -78,6 +77,9 @@ var showCourseData = function (label) { })); renderStudentProfile('repeat', section.current_repeating, section.current_enrollment); + + renderCoursePercentage1('current-declared-majors-chart', section.current_student_majors, 'major_name', 'percent_students'); + renderCoursePercentage1('current-concurrent-courses-chart', section.concurrent_courses, 'course_ref', 'percent_students'); } else { performanceTemplate = Handlebars.compile($("#historic-performance-template").html()); $("#current-performance-panel").html(performanceTemplate({ diff --git a/coursedashboards/static/coursedashboards/js/graphs.js b/coursedashboards/static/coursedashboards/js/graphs.js index b9fdb654..f3a26274 100644 --- a/coursedashboards/static/coursedashboards/js/graphs.js +++ b/coursedashboards/static/coursedashboards/js/graphs.js @@ -163,7 +163,6 @@ function renderCoursePercentage1(container, percentages, name_prop, percent_prop other = 100, chart_width = 240; - if (percentages) { $.each(percentages.slice(0, 9), function () { data.push([this[name_prop], Math.ceil(this[percent_prop])]); diff --git a/coursedashboards/static/coursedashboards/js/historic.js b/coursedashboards/static/coursedashboards/js/historic.js index 76c82af2..a3a54ab3 100644 --- a/coursedashboards/static/coursedashboards/js/historic.js +++ b/coursedashboards/static/coursedashboards/js/historic.js @@ -217,10 +217,19 @@ var showHistoricPerformanceData = function (section_label, data) { total_students: data.performance.enrollment, section_count: data.performance.offering_count, gpa_distribution_time: 'historic' - }); + }), + chart_container;; + + chart_container = $panel.find('#historic-median-cumulative-gpa'); + if (chart_container.length > 0) { + renderGPADisribution(chart_container[0], median_gpa, data.performance.gpas); + } + + chart_container = $panel.find('#historic-median-course-gpa'); + if (chart_container.length > 0) { + renderGPADisribution(chart_container[0], median_course_grade, data.performance.course_grades); + } - renderGPADisribution('historic-median-cumulative-gpa', median_gpa, data.performance.gpas); - renderGPADisribution('historic-median-course-gpa', median_course_grade, data.performance.course_grades); bind_events($panel); }; @@ -243,9 +252,13 @@ var showHistoricConcurrentCourses = function (section_label, data) { 'historic-concurrent-courses-template', { common_courses: data.concurrent_courses - }); + }), + chart_container; - renderCoursePercentage1('historic-concurrent-course-chart', data.concurrent_courses, 'course_ref', 'percent_students'); + chart_container = $panel.find('#historic-concurrent-course-chart'); + if (chart_container.length > 0) { + renderCoursePercentage1(chart_container[0], data.concurrent_courses, 'course_ref', 'percent_students'); + } bind_events($panel); @@ -280,9 +293,14 @@ var showHistoricStudentMajors = function (section_label, data) { 'historic-course-major-template', { common_majors: data.student_majors, - }); + }), + chart_container; + + chart_container = $panel.find('#historic-course-major-chart'); + if (chart_container.length > 0) { + renderCoursePercentage1(chart_container[0], data.student_majors, 'major_name', 'percent_students'); + } - renderCoursePercentage1('historic-course-major-chart', data.student_majors, 'major_name', 'percent_students'); bind_events($panel); }; @@ -305,9 +323,14 @@ var showHistoricGraduatedMajors = function (section_label, data) { 'historic-grad-major-template', { latest_majors: data.graduated_majors - }); + }), + chart_container; + + chart_container = $panel.find('#historic-graduated-major-chart'); + if (chart_container.length > 0) { + renderCoursePercentage1(chart_container[0], data.graduated_majors, 'major_name', 'percent_students'); + } - renderCoursePercentage1('historic-graduated-major-chart', data.graduated_majors, 'major_name', 'percent_students'); bind_events($panel); };