diff --git a/v2realbot/static/js/archivechart.js b/v2realbot/static/js/archivechart.js index 7a1795c..b2179cf 100644 --- a/v2realbot/static/js/archivechart.js +++ b/v2realbot/static/js/archivechart.js @@ -174,14 +174,7 @@ function prepare_data(archRunner, timeframe_amount, timeframe_unit, archivedRunn //render chart of archived runs function chart_archived_run(archRecord, data, oneMinuteBars) { - if (chart !== null) { - chart.remove() - clear_status_header() - indList = []; - if (toolTip !== null) { - toolTip.style.display = 'none'; - } - } + cleanup_chart() var transformed_data = transform_data(data) @@ -347,75 +340,8 @@ function chart_archived_run(archRecord, data, oneMinuteBars) { obj.series.setData(items) // add to indList array - pole zobrazovanych indikatoru - indList.push(obj); - - + indList.push(obj); } - - - - - - - - - - - - - - - - - // if (momentumIndicatorNames.includes(key)) { - // obj.series = chart.addLineSeries({ - // priceScaleId: 'left', - // color: colors.shift(), - // title: key, - // lineWidth: 1, - // lastValueVisible: false - // }); - - // if (key == "slopeMA") { - // const minSlopeLineOptopns = { - // //vzit odnekud jinud? - // price: data.statinds.angle.minimum_slope, - // color: colors.shift(), - // lineWidth: 1, - // lineStyle: 2, // LineStyle.Dotted - // axisLabelVisible: true, - // title: "max:", - // }; - - // const minSlopeLine = obj.series.createPriceLine(minSlopeLineOptopns); - // } - // } - // //ostatni - // else { - // obj.series = chart.addLineSeries({ - // title: key, - // color: colors.shift(), - // lineWidth: 1, - // lastValueVisible: false - // }); - // } - - // obj.series.applyOptions({ - // lastValueVisible: false, - // priceLineVisible: false, - // }); - - // try { - // obj.series.setData(items) - // } - // catch (error) { - // console.log("obj.series.setData(items)", items) - // console.error(error) - // } - - // //add to indList array - pole zobrazovanych indikatoru - // indList.push(obj); - } } } @@ -441,21 +367,21 @@ function chart_archived_run(archRecord, data, oneMinuteBars) { ); indList = []; //remove BASIC indicators - if (vwapSeries !== null) { + if (vwapSeries) { chart.removeSeries(vwapSeries) } - if (volumeSeries !== null) { + if (volumeSeries) { chart.removeSeries(volumeSeries) } } //displays (redraws) buy markers function display_buy_markers() { - if (avgBuyLine !== null) { + if (avgBuyLine) { chart.removeSeries(avgBuyLine) } - if (markersLine !== null) { + if (markersLine) { chart.removeSeries(markersLine) } diff --git a/v2realbot/static/js/utils.js b/v2realbot/static/js/utils.js index 4133e86..e767947 100644 --- a/v2realbot/static/js/utils.js +++ b/v2realbot/static/js/utils.js @@ -76,6 +76,23 @@ function update_chart_legend(param) { } } +//remove previous chart if exists and intiialize chart variables +function cleanup_chart() { + if (chart) { + chart.remove() + clear_status_header() + indList = []; + markersLine = null + avgBuyLine = null + volumeSeries = null + vwapSeries = null + if (toolTip !== null) { + toolTip.style.display = 'none'; + } + } + $( ".switcher" ).remove(); +} + function initialize_chart() { $('#chartContainerInner').addClass("show"); //PUVODNI BILY MOD