score:3
I have experience with both KO and Highcharts but weirdly I've never combined them in this manner. It would be nice to simply hold a KO model in memory that mimics the config object of HC and the two just play nice. Unfortunately this isn't going to happen as KO's observables are functions and HC expects pure json. You could do this but you'd have to destroy the chart each time and recreate with an unmapped copy of your KO model so probably not what you were thinking.
When you say dynamic I am assuming you mean the data only?
There are a number of methods on the chart/series objects documented here that can be used to connect your model to you chart. A really simple and incomplete way would be something like.
self.addUser = function() {
var user = new User("Foo", 0, 0, new Reading(0, 0));
self.users.push();
self.subscribe();
// chart handler
/// need to convert the readingsArray into a data array
chart.addSeries({ name: user.name, data: [180, 175, 195, 180] });
}
Alternatively you could subscribe to the users array and update the chart accordingly. (Note I didn't map your user readings data to the array but you get the idea)
viewModel.users.subscribe(function() {
.. update chart here
});
See here for more details on subscribing to observables.
Here is the fiddle I created to test this.
http://jsfiddle.net/madcapnmckay/uVTNU/
I'm afraid there is going to be a bit of manual mapping of your model objects to highchart's data format.
Hope this helps.
score:1
As with most 3rd-party plugins that manipulate the DOM, they are almost always best approached through the use of a custom binding handler. I don't have experience with Highcharts, but from the looks of it, it seems to take an approach to initialization and updating similar to other libraries that do well as custom KO bindings.
Source: stackoverflow.com
Related Query
- knockoutJS dynamic chart with high charts
- High charts queue chart updates after ajax with multiple charts in firefox
- High Charts - area chart with gradient & threshold
- High Charts Line Chart with missing data
- High charts Issue with stock bar chart multiple line series
- High Charts Polar / Spider chart with off-graph y-axis labels
- high chart column chart dynamic update with ajax
- High Charts for an area-spline chart with area fill on only one data set in series
- High charts bar chart label overlaps with the graph when labels are long
- How to append dynamic values to the area chart in High charts or convert the data to arrays?
- Highcharts Dynamic Updated Highstock Charts doesn't display along with Bar Chart
- High chart problwm with multiple axes with dynamic data
- Highcharts - how to have a chart with dynamic height?
- Add dynamic data to line chart from mysql database with highcharts
- High chart - Column Range Chart with Time range. How to get tooltip as Start and End time
- Laravel 5.5 Console TV Bar Chart High Charts multipleDatasets and label
- High charts - Increasing the space between chart and title
- Activity gauge High Chart with Range option
- HighChart Sparkline Chart with dynamic data for the table
- High charts AddAnnotation is not a function for dynamic adding
- Nested table yields unexpected columns for a basic column graph using high charts with 'Data defined in a HTML table'
- Add different symbols to highcharts chart with dynamic data
- Activity gauge High Chart with Gradient
- High Charts - Split color of bar chart
- Array split with the help of object categories values of array- Javascript - High Chart
- Drawing a small vertical line on top of chart using High charts by specifying end coordinates
- Remove the border around the pie chart in high charts
- High Charts Column Chart - Y axis Label Formatting
- Customizing the series data in pie charts with a dynamic json series (HighCharts)
- Ajax dynamic data with column bar chart
More Query from same tag
- How to plot Highcharter side by side in RStudio Viewer?
- Highstocks 2.04 Bug?: Tooltip dates > 20 years displaying as 1st of month
- same js highcharts display not the same
- How to remove white space around HighChart
- Highcharts hover bug - with video to demonstrate
- Legend in network graph ( Highchart Js)
- Highcarts: Hide xAxis categorie when serie is not visible
- How to apply borderRadius only for top side of Column or Bar in Highchart
- Min/Max on x-axis not honored in Highstocks version of xrange chart
- Highstock - custom x axis labels or force x axis labels for specific format
- How do you call a programmer-defined function in javascript in an android webview?
- Highcharts tree map showing wrong min value
- Highcharts numericSymbols when rendered server-side with Phantomjs
- highchart/highstock tooltip does not adjust after zoom
- JavaScript/Hightables - Add unique items with time and output percentage
- Initialising npm Highcharts 7 heatmaps in Angular 6
- Highstock Navigator and xAxis show numbers instead of dates
- Getting data from mysql and drawing a chart
- Highcharts plotLines with multiple xAxis and yAxis
- Highchart Spline with inverted axis categorie text left align
- Change map color on specific provinces
- How could I edit the color of the data elements in highchart graphic?
- How to display Date in Highcharts tooltip or below the categories
- Initialize Highcharts line chart from unknown number of points
- show .Net core web API response in highcharts
- Override table cell background color in highcharts-tooltip
- How to remove empty space between bars in Highcharts polar chart?
- Highcharts data doesn't show up correctly
- Gauge Series of Highcharts with React not the Solid Gauge but Gauge Series
- JSFiddle 'Please use Post Requst' error