score:1
You will want to setup an ajax request to the server that polls every X ms, preferably with jquery like this.
var ajax_path = #{action_controller_path}
function pollData() {
$.ajax({
type: 'get',
url: ajax_path,
success: function(data) {
// update chart
var series = chart.series[0],
shift = series.data.length > 20; // shift if the series is longer than 20
chart.series[0].addPoint(data, true, shift);
setTimeout(pollData, 60000) // Poll data every 60s
}
});
}
On the rails side you will then need to create a Controller#action to feed this ajax request, remember to set your your responds_to to include json. Something along the lines of this, please take this code "as is":
respond_to :json, only: [:polling_action]
def polling_action
@data_point = Model.get_data
respond_with @data_point
end
I think the specifics of how to actually update the chart is stated in the article @nikita-beloglazov referenced: http://www.highcharts.com/documentation/how-to-use and here http://www.highcharts.com/ref/#series-object for the addPoint (Object options, [Boolean redraw], [Boolean shift], [Mixed animation]) api reference which is what you should call after you have loaded the data point with the ajax polling method.
NOTE: Keep in mind polling data is not an very efficient process unless you know the interval at which the data is being updated. Considering you only need to update this data every 60s this is probably not an issue but just putting it out there for others that might stumble upon this.
score:1
There is an example of updating highchart in documentation: http://www.highcharts.com/documentation/how-to-use. Just implement method in controller which returns appropriate data for chart.
Source: stackoverflow.com
Related Query
- How to re-render a graph at a given interval that retrieves data from a controller in Rails?
- How to render Gantt Highchart from data source
- Ember.js and Highcharts: how to render a graph only after slow-loading model data has been loaded?
- How to render a line from dataLabels to marker on graph in HighCharts?
- How to plot a highstock single line series graph from ajax data
- How to pass all the data in dataframe that extract from excel sheet to highchart?
- How to modify the code so that Highcharts graph does not cover fixed navigation bar at the top of the page?
- How do I scrape data from a highcharts graph in python?
- I want delete the values from the series so that the graph is not cluttered how to do that
- How do I create a graph from JSON data in Ruby on Rails?
- How to display basic line graph in Highchart for multiple categories' data from csv?
- How to make stacked column graph to show total data value on top
- How to pass custom data into Highcharts graph click event
- Highcharts: How to load data from JSON to xAxis.categories and series.data?
- How to set second yAxis scale according to data from first yAxis
- How can i change highcharts data values by selecting from a dropdown list
- How to extract the data from highstock chart
- Highcharts: How to provide a custom stack label in highcharts bar graph from within the stackLabel formatter?
- How to populate a Highcharts axis with string formatted data from a PHP array
- How to make Highcharts fetch data from external JSON file?
- How can I make a graph with highcharts from csv file?
- How to extract data from an interactive chart?
- HighCharts & MVC: How to load whole graph definition and data with JSON?
- How to render the missing data series and fix the dates on the x-axis in Highcharts?
- How to load data from JSON to Highchart?
- How To Get Data From Database To Highcharts Plugin in cakephp
- How to feed series data that has x axis and y axis values in line highcharts?
- How to hardcode chart data in my Model then have my Controller pull it from there to display it. Using Highcharts
- How to remove sliced line from pie high chart if there there is only one object in data
- How to make data from ajax become X axis in Highchart?
More Query from same tag
- convert Unix epoch timestamps to JavaScript date timestamps
- Highcharts pointInterval
- How to add y value in piechart in highcharts as legend
- HighCharts. Change options dynamically
- Highcharts - Tooltip width in styled mode
- Controlling Highcharts bar chart look and layout
- How to show text as a series on a chart in Javascript?
- HighChart Stacked Column label issue
- Highcharts yAxis text rotation issue in IE8
- How to enable Highcharts marker clipping
- Highcharts column chart with two different scales
- Best performance for updating many Highcharts instances on demand
- Highcharts drilldown doesn't work for 3+ levels
- Bar chart data label and bar custom css with bar background,Highchart
- Highcharts data module and CSV: Displaying data points differently
- Scrollbar creating overlaping chart div
- Highcharts large treemap How do I get the clicked node data?
- Highcharts: Add Dynamic Data to xAxis Label
- highchart legend symbol is not appearing, for holo column
- highstock 1.3 / highcharts 3.0 beta navigator lagging
- max Y Axis value in a Highchart
- Last y-axis label not displaying on highcharts spiderweb
- Drilldown broken in Highcharts?
- How to avoid bad behavior zooming to areas outside the data range
- Limitation for data-set (items) with Highstock/Highcharts?
- highcharts yaxis start on 1 min:1 not working
- Highcharts: xAxis yearly labels centered between ticks
- Weekly PDF generation using PHP and Highcharts
- How to add plotline on highcharts with angle?
- Highcharts border around plot