protected void OnChartTypeChanged(String chartType) {
        selectedChart = chartType;
        if (lastData == null) {
            System.out.println("Original data is null, downloading it");
            OnDataRangeChanged();
            return;
        }

        if (chartType.equals("line")) {
            lineChart.getData().clear();
            LinearChartManager.addSeries(lineChart, lastData, selectedRange);
            borderPane.setCenter(lineChart);
        } else if (chartType.equals("candle")) {
            CandleChart.generateData(lastData);
            candleChart = new CandleChart();
            chart = candleChart.createChart();
            chart.setTitle(selectedIndex.getName());
            pane.getStylesheets().add("resources/css/CandleStickChart.css");
            borderPane.setCenter(chart);
            selectedChart = chartType;
        }
    }