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 Articles
- 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?
- Update Data Point From Existing DataTable On Set Interval
- parsing JSON data to render high chart graph
- Data from MongoDB results with empty Highcharts graph
- Can I add on the webpage, data that I get from a Highcharts function?
- Can I Create a Single HighCharts Graph from Multiple Data Sources (Multiple GoogleSheets in this case)
- How to plot a highstock single line series graph from ajax data
- Highcharts update graph from array data
- Scraping data from an interactive highchart.js graph
- The continuous update highcharts with more data plotting the continuity is not visible so we need that continuity in the centre of the graph
- How to pass all the data in dataframe that extract from excel sheet to highchart?
- HighCharts Bubble graph JSON as data source
- How to modify the code so that Highcharts graph does not cover fixed navigation bar at the top of the page?
- Highchart graph retrieve data from json url
- Line graph is not showing data from database
- Highchart json from mysql data not able to show up in line graph
- highcharts - to show a no data picture in case nothing to render from mysql query
- How do I scrape data from a highcharts graph in python?
- Scrape data from graph generated with Highcharts
- 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?
- Highcharts displays series names but missing data points from json source
- Strip/escape special characters from Google Spreadsheet field before passing data to Highcharts Graph
- High Chart inserting data from arrays into line graph
- live data from database into javascripted graph
- Proper way to remove all series data from a highcharts chart?
- Highcharts - How to set Pie Chart's background color dynamically
- Customize Highchart tooltip
- Remove padding from barcharts Highcharts.js
- Redraw issue in Highcharts 3D Scatter Chart
- Hide the zero values in a Scatter/Column chart in highcharts
- Highcharts change colour of individual bar
- Highcharts - SMA Indicator does not display
- Print Array in HighChart
- how to get the axis value when I click on a cursor in highstock(high charts)?
- Highcharts (rCharts) onclick tooltip
- Which javascript graphs / chart library?
- Changing the contents of Highcharts legend
- Highstock - Remove axis and series dynamically
- Php to JSON passed thru to high charts
- Changing themes using highcharts-angular
- Add plotbonds to Gaps defined by GapSize in Highcharts
- How to get current drilldown's id in Highcharts
- Using multiple hicharts on ASP.NET web form but only one shows on the upper section of the page pushing the page header down
- How to set point in highcharts when x axis and y axis has data as text values?
- Moving javascript data series to html data attribute breaks Highchart