diff --git a/package.json b/package.json index 6f16508..6e496ff 100644 --- a/package.json +++ b/package.json @@ -3,9 +3,14 @@ "description": "", "version": "0.0.1", "config": { - "prototype": "test" + "prototype": "jsvis" }, "scripts": { - "build-preview": "mkdir -p preview; cp -r prototypes/${npm_package_config_prototype}/* preview/." + "build-preview": "mkdir -p preview; cp -r prototypes/${npm_package_config_prototype}/* preview/." + }, + "dependencies": { + "bootstrap": "^5.3.3", + "css-loader": "^7.1.2", + "style-loader": "^4.0.0" } -} \ No newline at end of file +} diff --git a/prototypes/jsvis/bokehWrapper.js b/prototypes/jsvis/_old/bokehWrapper.js similarity index 91% rename from prototypes/jsvis/bokehWrapper.js rename to prototypes/jsvis/_old/bokehWrapper.js index 9b60ce9..02dd0cc 100644 --- a/prototypes/jsvis/bokehWrapper.js +++ b/prototypes/jsvis/_old/bokehWrapper.js @@ -21,16 +21,6 @@ function createGraph(fits_file, settings) { let scales = null; if(settings) { - console.log("Axis"); - console.log(settings['select-axis-x']); - console.log(settings['select-axis-y']); - - console.log("Error bars"); - console.log(settings['select-axis-x-error-bars']); - console.log(settings['select-axis-y-error-bars']); - - console.log(settings['select-axis-x']); - console.log(settings['select-axis-y']); let x_column = settings['select-axis-x'].value; let y_column = settings['select-axis-y'].value; diff --git a/prototypes/jsvis/d3Wrapper.js b/prototypes/jsvis/_old/d3Wrapper.js similarity index 79% rename from prototypes/jsvis/d3Wrapper.js rename to prototypes/jsvis/_old/d3Wrapper.js index b7b7bb0..f1d8cb3 100644 --- a/prototypes/jsvis/d3Wrapper.js +++ b/prototypes/jsvis/_old/d3Wrapper.js @@ -6,10 +6,19 @@ let margin = {top: 10, right: 30, bottom: 30, left: 60}, width = 800 - margin.left - margin.right, height = 400 - margin.top - margin.bottom; -function createGraph0(container, data, settings = null) { +function instantiateGraph(container, data, settings = null) { + +} + +function createGraphLightCurve(data, settings) { - console.log(data); - console.log(settings); +} + +function createGraphSpectrum(data, settings) { + +} + +function createGraph0(container, data, settings = null) { dataset = data; settings_data = settings; @@ -56,15 +65,6 @@ function createGraph0(container, data, settings = null) { if(settings) { - console.log("Axis settings"); - - console.log("Axis") - console.log(settings['select-axis-x-scale']); - console.log(settings['select-axis-y-scale']); - - console.log(settings['select-axis-x']); - console.log(settings['select-axis-y']); - let x_scale = settings['select-axis-x-scale'].value; let y_scale = settings['select-axis-y-scale'].value; @@ -74,10 +74,6 @@ function createGraph0(container, data, settings = null) { } try { - console.log("Error bars") - console.log(settings['select-axis-x-error-bars']); - console.log(settings['select-axis-y-error-bars']); - let error_bar_x_column = settings['select-axis-x-error-bars'].value; let error_bar_y_column = settings['select-axis-y-error-bars'].value; } catch(e) { @@ -167,10 +163,8 @@ function createGraph0(container, data, settings = null) { let y_data = 'RATE'; if(settings) { - console.log('settings'); x_data = settings['select-axis-x'].value; y_data = settings['select-axis-y'].value; - console.log(x_data + ' ' + y_data); } else { x_data = 'TIME'; y_data = 'RATE'; @@ -224,15 +218,9 @@ function createAxis(data, settings, _svg, width, height, scales) { "log": d3.scaleLog }; - console.log(settings['select-axis-x']); - console.log(settings['select-axis-y']); - let x_axis_col = settings['select-axis-x'].value; let y_axis_col = settings['select-axis-y'].value; - console.log("Axis columns"); - console.log(x_axis_col+" "+y_axis_col); - let _x = scale_functions[scales.x]() .domain(d3.extent(data, d => d[x_axis_col])) .range([ 0, width ]); @@ -280,8 +268,6 @@ function createAxis(data, settings, _svg, width, height, scales) { function updateChart(e) { - console.log(e); - let newX = e.transform.rescaleX(x); let newY = e.transform.rescaleY(y); @@ -323,10 +309,8 @@ function updateChart(e) { let y_data; if(settings_data) { - console.log('settings data'); x_data = settings_data['select-axis-x'].value; y_data = settings_data['select-axis-y'].value; - console.log(x_data + ' ' + y_data); } else { x_data = 'TIME'; y_data = 'RATE'; @@ -375,65 +359,3 @@ function updateChart(e) { }) */ } - -function createGraph1(container, data) { - - const margin = {top: 50, right: 30, bottom: 30, left: 60}, - width = 460, - height = 450; - - let svg = d3.select(container) - .append("svg") - .attr("width", width + margin.left + margin.right) - .attr("height", height + margin.top + margin.bottom) - .append("g") - .attr("transform", - "translate(" + margin.left + "," + margin.top + ")"); - - let x = d3.scaleLinear() - .domain(d3.extent(data, d => d.time)) - .range([ 0, width ]); - - let xAxis = svg.append("g") - .attr("id", "x_demo") - .attr("transform", "translate(0," + height + ")") - .call(d3.axisBottom(x) - .tickFormat(d3.format(".1f"))) - .call(g => g.selectAll(".tick line").clone() - .attr("class", "tick-line") - .attr("y2", -height) - .attr("stroke-opacity", 0.2)) - - let y = d3.scaleLinear() - .domain(d3.extent(data, d => d.rate)) - .range([ height, 0]); - - let ylog = d3.scaleLog() - .domain([1, d3.max(data, d => d.rate)]) - .range([ height, 0]); - - let yAxis = svg.append("g") - .attr("id", "y_demo") - .call(d3.axisLeft(y) - .tickFormat(d3.format(".1f"))) - .call(g => g.selectAll(".tick line").clone() - .attr("x2", width) - .attr("stroke-opacity", 0.2)); - - yAxis.select(".tick:last-of-type text").clone() - .attr("id", "y-label") - .attr("x", 3) - .attr("y", -5) - .attr("text-anchor", "start") - .attr("font-weight", "bold") - .text("Rate"); - - xAxis.select(".tick:last-of-type text").clone() - .attr("id", "y-label") - .attr("y", -11) - .attr("x", 2) - .attr("text-anchor", "start") - .attr("font-weight", "bold") - .text("Time"); - -} \ No newline at end of file diff --git a/prototypes/jsvis/fitsreaderWrapper.js b/prototypes/jsvis/_old/fitsreaderWrapper.js similarity index 87% rename from prototypes/jsvis/fitsreaderWrapper.js rename to prototypes/jsvis/_old/fitsreaderWrapper.js index 2210f85..9e4994e 100644 --- a/prototypes/jsvis/fitsreaderWrapper.js +++ b/prototypes/jsvis/_old/fitsreaderWrapper.js @@ -18,16 +18,15 @@ function getDataFromFITS(fits_file, hdu_index) { data.getColumn("RATE", function(col){y = col}); data.getColumn("ERROR", function(col){dy = col}); + /* x.forEach(function(d) { - console.log(d); - }) - console.log(data); + }) + */ let columns = []; data.columns.forEach(function(column) { - console.log(column); let col_name = column; let col_data_json = []; @@ -42,8 +41,6 @@ function getDataFromFITS(fits_file, hdu_index) { col_data.forEach(function(col) { let col_json_object = `{"${column}": ${col}}`; - console.log(col_json_object); - col_data_json.push(col_json_object); }) @@ -52,23 +49,15 @@ function getDataFromFITS(fits_file, hdu_index) { //console.log(JSON.stringify(col_data_json)); }) - console.log(fits_data); - console.log(raw_data_array); - fits_data['x'] = x; fits_data['y'] = y; fits_data['dy'] = dy; - console.log(fits_data); - //initializeHDUSettings(fits_file); initializeDatasetSettings(columns); initializeAxisSettings(columns); initializeErrorBarsSettings(columns); - console.log(raw_data_array); - - const column_names = Object.keys(raw_data_array); const fits_data_json = []; @@ -83,31 +72,23 @@ function getDataFromFITS(fits_file, hdu_index) { fits_data_json.push(obj); } - console.log(fits_data_json); - createGraph(fits_file); createGraph0('graph-container1', fits_data_json); - console.log("FITS DATA WRAPPER") let file_data = [fits_file, fits_data_json, columns]; - console.log(file_data); return file_data; } function initializeHDUSettings(fits_file) { - console.log(fits_file); let HDUs = []; let hdu_object = {}; fits_file.hdus.forEach(function(hdu, index) { - console.log(index); - console.log(hdu); let is_hdu_type_supported = false; if (hdu.header.primary === true) { - console.log("Primary"); hdu_object = { "name": "Primary", "index": index @@ -116,7 +97,6 @@ function initializeHDUSettings(fits_file) { is_hdu_type_supported = true; } else { - console.log(hdu.header.get('XTENSION')); let type = hdu.header.get('XTENSION'); if (type === 'BINTABLE' || type === 'TABLE') { @@ -134,8 +114,8 @@ function initializeHDUSettings(fits_file) { } }) - console.log(HDUs); setupHDUControls(HDUs); + setupDataContainerControls(HDUs); } function initializeDatasetSettings(columns) { @@ -166,17 +146,13 @@ function setupHDUControls(HDUs) { function setupDatasetControls(columns) { - console.log(columns); - let options_dataset = getDatasetsOptionsFromData(columns, null); let select_datasets = document.querySelectorAll(".select-dataset, .select-errorbar"); options_dataset.forEach(function(option) { - console.log(option); select_datasets.forEach(function(select_dataset) { - console.log(select_dataset); let cloned_option = option.cloneNode(true); select_dataset.add(cloned_option); }) @@ -186,8 +162,6 @@ function setupDatasetControls(columns) { function setupAxisControls(columns) { - console.log(columns); - let options_axis = getDatasetsOptionsFromData(columns, null); let select_axis = document.querySelectorAll(".select-axis"); @@ -197,10 +171,7 @@ function setupAxisControls(columns) { }) options_axis.forEach(function(option) { - console.log(option); - select_axis.forEach(function(select_axis) { - console.log(select_axis); let cloned_option = option.cloneNode(true); select_axis.add(cloned_option); }) @@ -210,17 +181,12 @@ function setupAxisControls(columns) { function setupErrorBarsControls(columns) { - console.log(columns); - let options_axis_error_bars = getDatasetsOptionsFromData(columns, null); let select_axis_error_bars = document.querySelectorAll(".select-axis-error-bars"); options_axis_error_bars.forEach(function(option) { - console.log(option); - select_axis_error_bars.forEach(function(select_axis_error_bar) { - console.log(select_axis_error_bar); let cloned_option = option.cloneNode(true); select_axis_error_bar.add(cloned_option); }) @@ -283,8 +249,6 @@ function getDatasetsOptionsFromData(columns, selected) { columns.forEach(function(column) { - console.log(column); - option = document.createElement("option"); option.value = column; @@ -303,12 +267,8 @@ function resetSettingsOptions() { div_ids.forEach(function(div_id) { - console.log(div_id); - div_select = document.getElementById(div_id); - console.log(div_select); - const selectElements = div_select.querySelectorAll('select:not(.static-select)'); selectElements.forEach(select => { @@ -323,8 +283,23 @@ function resetSettingsOptions() { }); } +function setupDataContainerControls(HDUs) { + let options_hdu = getHDUsOptionsFromData(HDUs, 'Primary'); + + let select_hdu = document.getElementById("select-data-hdus"); + + options_hdu.forEach(function(option) { + select_hdu.add(option); + }); + + select_hdu = document.getElementById("select-header-hdus"); + + options_hdu.forEach(function(option) { + select_hdu.add(option.cloneNode(true)); + }); +} + function setDataContainer(data) { - console.log(data); const table_element = document.getElementById('table-data'); const tbody = table_element.tBodies[0]; @@ -354,12 +329,27 @@ function setDataContainer(data) { } function setHeaderContainer(hdu) { - console.log(hdu); - const cards_array = Object.values(hdu.header.cards).filter(item => typeof item === 'object' && !Array.isArray(item)); + /* + const cards_array = Object.values(hdu.header.cards) + .filter(([key, item]) => typeof item === 'object' && !Array.isArray(item)); + */ + + const cards_array = []; + + Object.entries(hdu.header.cards).forEach(function(item) { + let item_value_array = item[1]; + + + if(typeof item_value_array === 'object' && !Array.isArray(item_value_array)) { + item_value_array['card_name'] = item[0]; + cards_array.push(item_value_array); + } + }) + + const cards_array_key = Object.keys(hdu.header.cards); let sorted_hdu_cards = cards_array.sort((a, b) => a.index - b.index); - console.log(sorted_hdu_cards); const table_element = document.getElementById('table-header-data'); @@ -372,10 +362,12 @@ function setHeaderContainer(hdu) { const index_cell = row.insertCell(0); - const name_cell = row.insertCell(1); - const description_cell = row.insertCell(2); + const card_cell = row.insertCell(1); + const name_cell = row.insertCell(2); + const description_cell = row.insertCell(3); index_cell.textContent = card.index; + card_cell.textContent = card.card_name; name_cell.textContent = card.value; description_cell.textContent = card.comment; }); diff --git a/prototypes/jsvis/_old/index.html b/prototypes/jsvis/_old/index.html new file mode 100644 index 0000000..ec91bd9 --- /dev/null +++ b/prototypes/jsvis/_old/index.html @@ -0,0 +1,242 @@ + + +
+ + + + + + + + + + + + + + + + + + +# | +Name | +Value | +Comment | +
---|