Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8001453
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T16:05:46+00:00 2026-06-04T16:05:46+00:00

I’ve searched and searched for the answer to this and cannot find it anywhere.

  • 0

I’ve searched and searched for the answer to this and cannot find it anywhere.

I have a highcharts line charts that reads data into 5 series from a CSV file, this works absolutely fine and plots well. The data in the CSV file is updated every hour (the latest value in each series will change) and currently I have to manually refresh (press F5) to refresh the actual chart data.

So far I have tried chart.destroy, series.remove, series,setData all to no avail, each time, the chart will destroy happily, then press the create new button and the chart comes back with all 5 series duplicated, each time I click create, it adds five new series to the chart rather than destroying it and recreating.

see code below:

var chart;

        $(document).ready(function() {
            var options = {
                chart: {
                    renderTo: 'linegr',
                    defaultSeriesType: 'line'
                },
                title: {
                    text: 'Malicious IPs BY Type'
                },
                xAxis: {
                    categories: []
                },
                yAxis: {
            title: {
                   text: 'Unique IPs'
                   }
                },
                subtitle: {
                    text: 'Last 10 Days'
                },
                tooltip: {
                    formatter: function() {
                    return '<b>'+ this.x +'</b>: '+ roundVal(this.y);
                    }
                },
                plotOptions: {
                    pie: {
                        allowPointSelect: true,
                        cursor: 'pointer',
                        dataLabels: {
                            enabled: false
                    },
                    showInLegend: true
                    }
                },
                series: [],
                exporting: {
        buttons: [
            {
                symbol: 'diamond',
                x: -62,
                symbolFill: '#B5C9DF',
                hoverSymbolFill: '#779ABF',
                _titleKey: 'reloadGraph',
                onclick: function() {
                chart.destroy();
                }
            }
        ]
    }
};
create();

function create() {
    $.get('dat.csv', function(data) {
    // Split the lines
    var lines = data.split('\n');

    // Iterate over the lines and add categories or series
    $.each(lines, function(lineNo, line) {
        var items = line.split(',');

        // header line containes categories
        if (lineNo == 0) {
            $.each(items, function(itemNo, item) {
                if (itemNo > 0) options.xAxis.categories.push(item);
            });
        }

        // the rest of the lines contain data with their name in the first position
        else {
            var series = {
                data: []
            };
            $.each(items, function(itemNo, item) {
                if (itemNo == 0) {
                    series.name = item;
                } else {
                    series.data.push(parseFloat(item));
                }
            });

            options.series.push(series);

        }

    });

    // Create the chart
    var chart = new Highcharts.Chart(options);
function destroy() {
    chart.destroy();
    var data='';
            window.alert(chart.series.length);
    for(i=0; i<chart.series.length; i++){
        chart.redraw(true);
        chart.series[i].remove(false);
    }
        }
        $('#create').click(create);
        $('#destroy').click(destroy);
});

I’m hoping and guessing that its something really simple and stupid that I’ve just become code blind to and cant find 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T16:05:47+00:00Added an answer on June 4, 2026 at 4:05 pm

    I think your problem is that you are reusing the same options object each time you create the chart. Try cloning the default options, then modify the cloned object to create the chart options. You can use jQuery’s extend method to do this. Just make sure that you create new arrays for the categories and series each time, like so:

    (function(){
        var chart,
        options = {
            chart: {
                renderTo: 'linegr',
                defaultSeriesType: 'line'
            },
            title: {
                text: 'Malicious IPs BY Type'
            },
            xAxis: {
                categories: []
            },
            yAxis: {
        title: {
               text: 'Unique IPs'
               }
            },
            subtitle: {
                text: 'Last 10 Days'
            },
            tooltip: {
                formatter: function() {
                return '<b>'+ this.x +'</b>: '+ roundVal(this.y);
                }
            },
            plotOptions: {
                pie: {
                    allowPointSelect: true,
                    cursor: 'pointer',
                    dataLabels: {
                        enabled: false
                },
                showInLegend: true
                }
            },
            series: [],
            exporting: {
                buttons: [
                    {
                        symbol: 'diamond',
                        x: -62,
                        symbolFill: '#B5C9DF',
                        hoverSymbolFill: '#779ABF',
                        _titleKey: 'reloadGraph',
                        onclick: function() {
                                            create();
                        }
                    }
                ]
            }
        };
    
        function create() {
                if(chart) chart.destroy();
            $.get('dat.csv', function(data) {
                var newOptions = $.extend(true, {}, options, {
                    xAxis : {
                        categories : []
                    },
                    series : []
                });
    
                // Split the lines
                var lines = data.split('\n');
    
                // Iterate over the lines and add categories or series
                $.each(lines, function(lineNo, line) {
                    var items = line.split(',');
    
                    // header line containes categories
                    if (lineNo == 0) {
                        $.each(items, function(itemNo, item) {
                            if (itemNo > 0) newOptions.xAxis.categories.push(item);
                        });
                    }
    
                    // the rest of the lines contain data with their name in the first position
                    else {
                        var series = {
                            data: []
                        };
                        $.each(items, function(itemNo, item) {
                            if (itemNo == 0) {
                                series.name = item;
                            } else {
                                series.data.push(parseFloat(item));
                            }
                        });
    
                        newOptions.series.push(series);
    
                    }
    
                });
    
                // Create the chart
                chart = new Highcharts.Chart(newOptions);
    
                $('#create').click(create);
                $('#destroy').click(chart.destroy);
            });
        }
    
        $(document).ready(create);
    }());
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have some data like this: 1 2 3 4 5 9 2 6
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
Seemingly simple, but I cannot find anything relevant on the web. What is the
That's pretty much it. I'm using Nokogiri to scrape a web page what has

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.