Skip to content

Commit 3036472

Browse files
committed
Added more comments
1 parent e8906d8 commit 3036472

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

js/widgets/main_plot.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -804,6 +804,7 @@ $(function() {
804804
},
805805

806806
import: function(data) {
807+
// Import data from JSON object
807808
if ("combined" in data) {
808809
this.toggle_combined(data.combined, false);
809810
$("#axes-input").axes_input("toggle_combined", data.combined);
@@ -853,6 +854,7 @@ $(function() {
853854
},
854855

855856
reset: function() {
857+
// Reset plot to default settings
856858
this.combined = false;
857859
this.locked = false;
858860
this.title = "Composite Plot";
@@ -868,6 +870,7 @@ $(function() {
868870
.property("disabled", false);
869871
$("#settings-dropdown").settings_dropdown("set_value", "none");
870872

873+
// Clear plot
871874
this._elements.main_plot.selectAll("*").remove();
872875
this._elements.composites = [];
873876
this._elements.legend_items = [];
@@ -889,6 +892,7 @@ $(function() {
889892
},
890893

891894
_create: function() {
895+
// Create text label
892896
let label_group = d3.select(this.element.context);
893897
this.text_label = label_group.append("text")
894898
.attr("x", this.options.x)
@@ -905,6 +909,7 @@ $(function() {
905909

906910
toggle_input: function(ev) {
907911
let label_group = d3.select(this.element.context);
912+
// Hide text label and create input box
908913
this.text_label.style("display", "none");
909914
this.foreign_object = label_group.append("foreignObject")
910915
.attr("x", this.options.x - 200)
@@ -931,12 +936,17 @@ $(function() {
931936
},
932937

933938
enter_input: function(ev) {
939+
// ev.keyCode === 13 is the enter/return key
934940
if (ev.keyCode === 13) {
941+
// Remove input box
935942
this.foreign_object.remove();
936943

944+
// TODO: User can still submit a whitespace string, making the label uneditable
937945
if (ev.target.value.trim().length !== 0) {
946+
// Change the text label if the input field is not empty
938947
this.change_label(ev.target.value)
939948
} else {
949+
// Otherwise, reset the text label to the original text
940950
this.text_label.style("display", null)
941951
};
942952

@@ -946,8 +956,10 @@ $(function() {
946956

947957
change_label: function(new_label) {
948958
this.options.text = new_label;
959+
// Show text label and change text
949960
this.text_label
950961
.style("display", null)
962+
// If the label is the y-axis label, add the y-axis suffix
951963
.html(new_label + (this.options.label === "ylabel" ? $("#main-plot").main_plot("instance")._elements.ylabel_suffix : ""));
952964

953965
$("#main-plot").main_plot("change_label", this.options.label, new_label)

0 commit comments

Comments
 (0)