score:1
Accepted answer
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);
}());
Source: stackoverflow.com
Related Query
- highcharts refresh CSV data is duplicating not refreshing
- Highcharts not displaying data but drawing chart when reading from CSV file
- Not able to load local csv data into Highcharts
- Highcharts series visibility with csv data source
- Error: Data source must be a URL for refresh | console error | javascript | Highcharts
- Highcharts cloud issue with data source when duplicating chart
- Highcharts chart not displaying data from csv file
- Highcharts not displaying data labels for Pie chart in arabic
- Highcharts not displaying data at some zoom levels
- Highcharts stacked bar chart hide data labels not to overlap
- data label is not shown Highcharts
- Creating a line graph with highcharts and data in an external csv
- Exporting highcharts data to CSV file
- Highcharts - Global configuration with common code and unique data & Headings
- Highcharts x axis date full range even if there is not enough data
- Highcharts not displaying series data for graph with multiple Y-axes
- Data Not Showing in Highcharts
- Highcharts will not render if element in series data is empty
- load data in highcharts from 2 different csv files
- Highcharts - Gauge chart data label not positioning correctly
- Filename not assigned to csv export in HighCharts on Mac
- Firebase data not plotting in HighCharts
- Load CSV data via Ajax for display in Highcharts
- Not able to draw a Pie Chart with external csv file in HighCharts
- Highcharts Stock - rangeSelector results are not consistent - 3M showing 5 months data
- How to Load More Than One CSV Using Highcharts Data Module
- Negative values in the data not showing in highcharts linechart
- HighCharts Angular - data from API not showing in chart
- How to process csv data (datetime) month, week, day, hour in highstock highcharts
- Highcharts series data array not working
More Query from same tag
- Highcharts - how to add additional information to chart
- Is it possible to include maplines in highcharter maps?
- highchart load the chart but not the JSON data
- Highcharts scatter plot - make tooltip not follow pointer
- Single Quotes not showing up properly in HighCharts graph
- Use.js to set the height of highcharter plot and shinydashboard box
- How to use drilldown upto level 3 with different charts on each level in highcharts?
- JQuery mobile and highcharts integration
- Highcharts Gantt avoid tooltip closure when moving cursor outside Gantt
- Highcharts - Markers in line charts move up when leaving hovering
- How to get y-axis boundary line using highchart?
- Offline exporting a Highcharts chart using an external button
- How to edit the tooltip text in a highcharts boxplot
- Highcharts graph not shown in Yii2
- Pop up informations on a drilldown chart using Highcharts
- How to place dataLabels on series point in Highcharts
- Highcharts - show custom tooltip on mouseOver and on mouse Click
- how to reset Highchart chart width in percentage on Button click
- Highchart limiting number of series by default
- Showing up highchart after submitting form in other file
- How to add exporting date and time as user format in Highcharts exporter?
- Highcharts(highstock), how to Pass the dates to the navigator
- Uncaught TypeError: Cannot read property 'timestamp' of undefined
- Highstock - Timeaxis ticks not continuos
- Not able to animate solid gauge chart with Angular Highcharts
- Shared Tooltip error during mouse click event in highcharts
- ReactDOM.render into a <div> does not immediately produce HTML
- In Highcharts, how do I make my piechart label text the same color as the pie part?
- How to use loops for categories in Highcharts
- Highcharts: Styling input-group