score:3
As the doc of Highcharts says, "The point options. If options is a single number, a point with that y value is appended to the series.If it is an array, it will be interpreted as x and y values respectively." So just give an array as the parameter of addPoint()
.
To remove a point, use removePoint.
Here is the example which add the point in the position "i", and remove the point in the position "i":
$(function () {
$('#container').highcharts({
series: [{
data: [29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4]
}]
});
// the button action
var i = 0;
$('#button').click(function () {
var chart = $('#container').highcharts();
chart.series[0].addPoint([i, 50 * (i % 3)]);
i += 1;
});
$('#removebutton').click(function () {
var chart = $('#container').highcharts();
chart.series[0].removePoint(i);
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://code.highcharts.com/highcharts.js"></script>
<div id="container" style="height: 400px"></div>
<button id="button" class="autocompare">Add point</button>
<button id="removebutton" class="autocompare">remove point</button>
score:2
You need to specify both the x and y coordinates, otherwise it is going to assume that the x coordinate is the next data point on the x axis. Try this:
$(function () {
$('#container').highcharts({
series: [{
data: [29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4]
}]
});
// the button action
var i = 0;
$('#button').click(function () {
var chart = $('#container').highcharts();
chart.series[0].addPoint({
x: 2*i, // or some other value
y: 50 * (i % 3)
});
i += 1;
});
});
Source: stackoverflow.com
Related Query
- append point in the middle of graph
- How do I get the value of a highcharts graph point on mouseover?
- Click a point on a highcharts graph from outside of the chart
- how to continue the graph line when missing series of data in middle of highcharts
- Strange character in the Highstock source code
- Plot xrange graph in x axis not in the middle
- How to modify the code so that Highcharts graph does not cover fixed navigation bar at the top of the page?
- How to change the point color to red that is lowest point plotted in the graph and 2nd issue is animation effect is not supporting in the ie10,ie8
- The graph is not equal on the basis of the addition code in Highcharts
- High charts remove dots from the line graph
- Highcharts => Getting the id of a point when clicking on a line chart
- How to get Highcharts X-Axis Categories starting at the left most point
- Rotated X-Axis labels overlap the graph itself
- Set stacking column graph colors from the bottom up
- Click event on clicking on the graph
- Changing the color of the point dynamically in highcharts
- Adding only one clickable point to the chart in Highcharts?
- How do I set highcharts line graph point colors to an array of colors?
- highcharts zero values results in graph half way instead at the bottom
- Highchart - line or area not starting at the left point
- How to show always the pop-up at the point in a cloud graph?
- Get name of clicked point in Highcharts when the point has drilldown
- Highcharts: How to provide a custom stack label in highcharts bar graph from within the stackLabel formatter?
- What are the plotX, plotY values of a point in HighCharts?
- Highcharts: Placement of data labels in the middle of sections of Pie Chart
- How to add point to the beginning of series, Highcharts
- Highcharts - Rotate pie chart aligning the clicked section to a fixed point (180°)
- Getting the complete XML source out of an XML DOM object
- Highmaps: what is the code for a county?
- How to get the highlighted point from shared tooltip formatter, Highcharts
More Query from same tag
- Highcharts update x-axis categories dynamically
- How to display highchart y axis with constistant data
- Highcharts - Gantt Chart plot issue
- How to convert datetime string to UTC to plot points on Highcharts
- Highcharts - Show Year label in x-axis on change
- Is it possible to insert javascript charts into a JavaFX application
- Highcharts bar chart with negative and positive data
- react-highcharts: canvas size changes when changing tabs
- Very wide columns in stacking column graph
- Highcharts legend alignments
- Format date string into highcharts
- Chrome won't display the x-axis labels in Highcharts, Safari and Firefox do it
- Trying to get Gridster to call functions like disable but $('.gridster ul').gridster().data('gridster'); not working
- PhantomJS PDF DPI scaling issues
- this.point.properties undefined highmaps
- Edit click event on Highcharts Legend
- Tooltip doesn't appearing for overlapping datapoints in highchart xrange
- Calculate Y-axis breaks
- Highchart multiple-color line series dynamically
- How to remove Hyper Link in XAxis name in Highcharts?
- iterate JSON response with jQuery for Highcharts
- Highstock custom datagrouping datetimelabelformats timeseries
- Highcharts column chart. Sometimes unusable 1px stacked columns. Sometimes usable side by side columns
- rails and highcharts column chart
- Highcharts Dynamic update pie Chart mysql
- Paint segment of highcharts chart
- Issue with Dates - trying to plot MongoDB data in Highcharts via PHP
- Highchart | Grouped stacked bar chart | Multiple stack labels
- Highcharts Polar Chart customization
- R Highcharter: Formatting tooltip