M
M
MrJobs2020-05-03 18:14:48
JavaScript
MrJobs, 2020-05-03 18:14:48

AnyChart how to do?

Hello.
I can't figure out how to implement.
Briefly about what I'm doing, I'm doing Chars on the base of anychart. The chart loads everything well, but there is a select on the page, when selected, the ticker changes and, accordingly, the chart
. But anychart, when the ticker changes, creates a new container, and does not give the result to the old chart.
Tell me what can you think of?

Anichart code snippet

anychart.onDocumentReady(function () {
    // The data used in this sample can be obtained from the CDN
    // https://cdn.anychart.com/csv-data/weather-data.csv
    anychart.data.loadCsvFile('../'+tickerHistory+'.json', function (data) {

// set the input date/time format
anychart.format.inputDateTimeFormat("MM/dd HH:mm");      
        // create data table on loaded data
        var dataTable = anychart.data.table();
        dataTable.addData(data);

        // map loaded data
        var historyMapChart = dataTable.mapAs({'value': 1});


        var amountMapChart = dataTable.mapAs({'value': 2});

        // create stock chart
        var chart = anychart.stock();

        // create temperature plot on the chart
        var temperaturePlot = chart.plot(0);

        // create temperature plot series with mapped data
        temperaturePlot.line(historyMapChart ).name('History');
        temperaturePlot.yGrid(true)
                .yMinorGrid(true);

        // create DP Total temperature plot on the chart with column series
        var dpTotalRainPlot = chart.plot(1);
        dpTotalRainPlot.height('20%');
        dpTotalRainPlot.column()
                .name('Amount')
                .data(amountMapChart)
                .fill('#ef6c00');



        // set chart selected date/time range
        chart.selectRange('2008-04-01', '2008-09-28');
        // set container id for the chart
        chart.container('container-chart');
        // initiate chart drawing
        chart.draw();

        // create range picker
        var rangePicker = anychart.ui.rangePicker();
        // init range picker
        rangePicker.render(chart);

        // create range selector
        var rangeSelector = anychart.ui.rangeSelector();
        // init range selector
        rangeSelector.render(chart);
    });
});

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question