6 <script src="https://cdn.jsdelivr.net/npm/vega@5"></script>
7 <script src="https://cdn.jsdelivr.net/npm/vega-lite@5"></script>
8 <script src="https://cdn.jsdelivr.net/npm/vega-embed@6"></script>
10 <& /page/page_title.mas, title => "Breeding Progress" &>
12 <& /util/import_javascript.mas, classes => [ 'CXGN.BreedersToolbox.HTMLSelect' ] &>
16 <th width="100">Select Trait</th>
22 <div id="trait_selector_div">[loading...]</div>
29 <button class="btn" id="display_stats_button">Show Stats</button>
31 <table id="progress_stats_datatable">
34 <button class="btn" id="display_graph_button">Show Graph</button>
35 <div id="trait_averages_bargraph"></div>
37 jQuery(window).ready(function () {
38 get_select_box('traits', 'trait_selector_div', { 'name': 'trait_progress', 'id': 'trait_progress_select', 'empty': 1 });
43 jQuery('#display_stats_button').click(function () {
44 var trait_id = jQuery('#trait_progress_select').val();
45 jQuery('#progress_stats_datatable').DataTable({
46 ajax: '/ajax/progress?trait_id=' + trait_id,
50 { "title": "average" },
51 { "title": "std dev" },
52 { "title": "observations [count]" }
57 jQuery('#display_graph_button').click(function () {
59 var trait_id = jQuery('#trait_progress_select').val();
61 url: '/ajax/progress?trait_id=' + trait_id,
62 success: function (r) {
67 for (var i = 0; i < r.data.length; i++) {
68 years.push(r.data[i][0]);
69 averages.push(r.data[i][1]);
70 errorUp.push(r.data[i][1] / 1.0 + r.data[i][2] / 1.0); // im aware
71 errorDown.push(r.data[i][1] / 1.0 - r.data[i][2] / 1.0);
74 for (var i = 0; i < r.data.length; i++) {
75 graphData.push({ "Year": years[i], "Average": averages[i], "mean + stddev": errorUp[i], "mean - stddev": errorDown[i] })
78 "$schema": "https://vega.github.io/schema/vega-lite/v5.json",
90 "axis": { "labelAngle": 0 },
103 "type": "quantitative",
108 "mark": { "type": "errorband" },
111 "field": "mean + stddev",
112 "type": "quantitative",
113 "scale": { "zero": false },
116 "y2": { "field": "mean - stddev" },
117 "color": {"value": "navy"}
123 vegaEmbed("#trait_averages_bargraph", v);
126 error: function (e) {
127 alert('cannot show graph');