Skip to content

Commit

Permalink
Merge pull request #30 from CEGRcode/dev
Browse files Browse the repository at this point in the history
Merge from dev branch
  • Loading branch information
jcha40 authored Jun 21, 2023
2 parents f087bdc + 0cc651e commit ea01283
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
12 changes: 6 additions & 6 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,17 @@
<div class="row" style="padding-top:5px;">
<div class="col-4">
<div class="row">
<div class="col">
<input type="button" id="json-button" value="Import JSON">
<div class="col-8">
<input type="button" id="json-button" value="Import JSON session">
<input type="file" id="json-loader" style="display:none;">
<script src="js/events/import_json_button.js"></script>
<input type="button" id="json-download" value="Export JSON">
<input type="button" id="json-download" value="Export session as JSON">
<script src="js/events/export_json_button.js"></script>
<input type="button" id="tsv-download" value="Export TSV">
<input type="button" id="tsv-download" value="Export metadata as TSV">
<script src="js/events/export_tsv_button.js"></script>
</div>
<div class="col text-right">
<input type="button" id="load-composite-button" value="Load composite file">
<div class="col-4 text-right">
<input type="button" id="load-composite-button" value="Load multi-composite">
<input type="file" id="composite-loader" style="display:none;">
<script src="js/events/load_composite_button.js"></script>
</div>
Expand Down
12 changes: 12 additions & 0 deletions js/widgets/main_plot.js
Original file line number Diff line number Diff line change
Expand Up @@ -804,6 +804,7 @@ $(function() {
},

import: function(data) {
// Import data from JSON object
if ("combined" in data) {
this.toggle_combined(data.combined, false);
$("#axes-input").axes_input("toggle_combined", data.combined);
Expand Down Expand Up @@ -853,6 +854,7 @@ $(function() {
},

reset: function() {
// Reset plot to default settings
this.combined = false;
this.locked = false;
this.title = "Composite Plot";
Expand All @@ -868,6 +870,7 @@ $(function() {
.property("disabled", false);
$("#settings-dropdown").settings_dropdown("set_value", "none");

// Clear plot
this._elements.main_plot.selectAll("*").remove();
this._elements.composites = [];
this._elements.legend_items = [];
Expand All @@ -889,6 +892,7 @@ $(function() {
},

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

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

enter_input: function(ev) {
// ev.keyCode === 13 is the enter/return key
if (ev.keyCode === 13) {
// Remove input box
this.foreign_object.remove();

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

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

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

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

0 comments on commit ea01283

Please sign in to comment.