diff --git a/js/app/views/PlotComponents/plotFunction/CreatePlot.js b/js/app/views/PlotComponents/plotFunction/CreatePlot.js deleted file mode 100644 index 27385a8..0000000 --- a/js/app/views/PlotComponents/plotFunction/CreatePlot.js +++ /dev/null @@ -1,195 +0,0 @@ -/** - * Un composant de 'PlotFunction' qui permet à l'utilisateur de séléctionner le type de fonction à appliquer : FFT, SUM, ... - */ -Ext.define('amdaPlotComp.plotFunction.CreatePlot', { - extend: 'Ext.window.Window', - requires: [ - 'amdaUI.PlotlyContainer' - ], - - initComponent: function () { - - this.emptyChartConfig = { - xtype: 'amdaUI.PlotlyContainer', - id: 'visu-chart', - }; - - const config = - { - title: 'Apply a Function on Interval', - width: 700, - height: 500, - layout: 'fit', - bodyStyle: { background: '#FFFFFF' }, - modal: false, - resizable: true, - maximizable: true, - items: [ - this.emptyChartConfig - ] - }; - - Ext.apply(this, config); - this.callParent(arguments); - }, - - getXYData: function (data, serie_label) { - const separatorItems = "|"; - const separator = ";"; - - let legends = serie_label.split(separator); - legends.pop(); - - let items = data.split(separatorItems); - items.pop(); - - const xs = []; - const ys = []; - const labels = []; - for (j = 0; j < legends.length; j++) { - let i; - const y = []; - const x = []; - for (i = 0; i < items.length; i++) { - const temp = items[i].split(separator); - x.push(this.timeConverter(temp[0])); - y.push(temp[j + 1]); - } - ys.push(y); - xs.push(x); - labels.push(legends[j]); - } - - return { xs: xs, ys: ys, labels: labels }; - }, - - timeConverter: function (_timestamp) { - var a = new Date(_timestamp * 1000); - var year = a.getUTCFullYear(); - var month = a.getUTCMonth() + 1; - var date = a.getUTCDate(); - var hour = a.getUTCHours(); - var min = a.getUTCMinutes(); - var sec = a.getUTCSeconds(); - var time = year + '-' + month + '-' + date + ' ' + hour + ':' + min + ':' + sec; - return time; - }, - - applyFunction: function (y, dimSize) { - const type = this.plotFunctionType; - const valDict = type.getValues(); - const fct = valDict[type.plotFunctionItems.type.name]; - let out_y = []; - switch (fct) { - case type.plotFunctionItems.type.values.sum: - out_y = y; - break; - case type.plotFunctionItems.type.values.fft: - - break; - case type.plotFunctionItems.type.values.avg: - if (dimSize === -1) { - out_y = y.map(e => e / y.length); - } else { - out_y = y.map(e => e / dimSize); - } - break; - - default: - break; - } - return out_y; - }, - - - - plot: function () { - const param = this.xmlDoc.getElementsByTagName('parameter'); - const traces = []; - let yAxisLabel = ""; - let i; - for (i = 0; i < param.length; i++) { - const param_name = param[i].getAttribute('name'); - const param_unit = param[i].getAttribute('unit'); - const serie = param[i].getElementsByTagName('serie'); - - yAxisLabel += param_unit + "<br>"; - - for (let si = 0; si < serie.length; si++) { - const serie_label = serie[si].getAttribute('serie_label'); - const data_ = this.getXYData(serie[si].getAttribute('data'), serie_label); - let k; - - const dimSize = serie[si].getAttribute('dimSize'); - - for (k = 0; k < data_.ys.length; k++) { - let trace = {}; - trace.x = data_.xs[k]; - trace.y = this.applyFunction(data_.ys[k], parseInt(dimSize)); - trace.mode = 'lines+markers'; - trace.name = param_name + " (" + data_.labels[k] + ")"; - trace.type = 'scatter'; - - traces.push(trace); - } - } - } - - var chart = Ext.getCmp(this.emptyChartConfig.id); - - var config = this.emptyChartConfig; - - config.data = traces; - - const config_ = { - showgrid: true, - zeroline: true, - showline: true, - mirror: 'ticks', - gridcolor: '#bdbdbd', - gridwidth: 1, - zerolinecolor: '#969696', - zerolinewidth: 1, - linecolor: '#636363', - linewidth: 1 - }; - - let config_x = { - title: { - text: "Time, UT" - }, - type: 'date', - }; - - let config_y = { - title: { - text: this.format_label(yAxisLabel) - }, - exponentformat: "e" - } - - for (var key in config_) { - config_x[key] = config_[key]; - config_y[key] = config_[key]; - } - - config.layout = { - xaxis: config_x, - yaxis: config_y - }; - - if (chart) { - var chartPanel = chart.up(); - chartPanel.remove(chart); - } - var testPlotly = new amdaUI.PlotlyContainer(config); - chartPanel.insert(testPlotly); - }, - format_label: function (label) { - const power_2 = "\xB2"; - const power_3 = "\xB3"; - const amda_power_2 = "#u2"; - const amda_space = "#d"; - return label.replace(amda_power_2, power_2).replace(amda_space, " "); - } -}); \ No newline at end of file diff --git a/js/app/views/PlotComponents/plotFunction/FunctionType.js b/js/app/views/PlotComponents/plotFunction/FunctionType.js index 9803dcf..5d00460 100644 --- a/js/app/views/PlotComponents/plotFunction/FunctionType.js +++ b/js/app/views/PlotComponents/plotFunction/FunctionType.js @@ -96,11 +96,7 @@ Ext.define('amdaPlotComp.plotFunction.FunctionType', { initComponent: function () { this.view = Ext.create('Ext.form.FieldSet', { collapsible: false, - layout: { - type: 'vbox', - pack: 'start', - align: 'stretch', - }, + layout: LAYOUT_STYLE, bodyStyle: 'background: none', items: [this.createFunctionComboBox(), this.createAxisComboBox(this.x_axis), this.createAxisComboBox(this.y_axis)] }); @@ -135,7 +131,7 @@ Ext.define('amdaPlotComp.plotFunction.FunctionType', { // Adding values to out Object.assign(out, values); } - + return out; } }); \ No newline at end of file diff --git a/js/app/views/PlotComponents/plotFunction/ParamField.js b/js/app/views/PlotComponents/plotFunction/ParamField.js deleted file mode 100644 index 83c7042..0000000 --- a/js/app/views/PlotComponents/plotFunction/ParamField.js +++ /dev/null @@ -1,124 +0,0 @@ -/** - * Un composant de 'PlotFunction' qui permet d'afficher le min samplig de chaque paramètre et le nombre de points théoriques entre un start time et stop time - */ -Ext.define('amdaPlotComp.plotFunction.ParamField', { - extend: 'Ext.form.Panel', - /** - * id du composant de type numberfield qui hébérge le min sampling - */ - label_number_field: "NUMBERFIELD", - /** - * id du composant de type numberfield qui hébérge le nombre de points - */ - label_number_field1: "NUMBERFIELD1", - /** - * Le composant parent de celui-ci - */ - parent: null, - - initComponent: function () { - const items_params = []; - const minSampling = "Sampling Time (s)"; - const minValue = 0; - const labelWitdh = 120; - const width = 30; - - for (p in this.params) { - const param = this.params[p]; - const fieldSet = { - xtype: 'fieldset', - name: 'FIELDSET' + param.id, - title: param.id, - collapsible: false, - layout: { - type: 'vbox', - align: 'stretch', - }, - items: [ - { - xtype: 'numberfield', - name: this.label_number_field + param.id, - labelWidth: labelWitdh, - width: width, - value: param.MinSampling, - minValue: minValue, - disabled: true, - fieldLabel: minSampling - }, - { - xtype: 'numberfield', - name: this.label_number_field1 + param.id, - labelWidth: labelWitdh, - width: width, - value: 0, - minValue: minValue, - fieldLabel: "Nb Points" - } - ] - }; - - items_params.push(fieldSet); - } - - const tabParams = Ext.create('Ext.tab.Panel', { - layout: 'fit', - plain: true, - bodyStyle: 'background: none', - items: items_params - }); - - const config = - { - title: 'Parameters Sampling', - layout: 'fit', - bodyStyle: { background: '#dfe8f6' }, - items: [tabParams] - }; - - Ext.apply(this, config); - //Les arguments sont les paramètres, chaque paramètre contient un id et un min Sampling - this.callParent(arguments); - }, - - /** - * Set parent - * @param {*} parent_ le parent qui contient ce composant - */ - setParent: function (parent_) { - this.parent = parent_; - }, - - /** - * Retourne les valeurs d'id, min sampling et nb_points de tout les parametres passés comme argument - * @returns id1@minSampling1@nb_points1@id2@minSampling2@nb_points2.... - */ - getValues: function () { - let list = ""; - const delimeter = "@"; - let i = 0; - for (p in this.params) { - let param = this.params[p]; - const ui_item = this.parent.findField(this.label_number_field1 + param.id); - if (i > 0) list += delimeter; - if (ui_item !== undefined && ui_item !== null) { - list += param.id + delimeter + param.MinSampling + delimeter + ui_item.getValue() + delimeter + "5"; - } - i++; - } - return { "param_nb_points": list }; - }, - - /** - * Mettre à jour le nb_points en fonction de la valeur de start time et stop time passés en paramètres - * @param {*} startTime le start time issu du ZoomPlugin - * @param {*} stopTime le stop time issu du ZoomPlugin - */ - setValues: function (startTime, stopTime) { - for (p in this.params) { - let param = this.params[p]; - const nb_points = (stopTime.getTime() - startTime.getTime()) / (1000. * param.MinSampling); - const ui_item = this.parent.findField(this.label_number_field1 + param.id); - ui_item.setValue(parseInt(nb_points)); - } - } -}); -- libgit2 0.21.2