Your search did not match any results.
Charts

SignalR Service

This example demonstrates real-time data update in a financial chart bound to a SignalR server. Note that data used in this demo is for demonstration purposes only.

Copy to CodePen
Apply
Reset
$(function(){ $.connection.hub.url = "/Demos/Mvc/signalr"; var hub = $.connection.stockTickDataHub; var store = new DevExpress.data.CustomStore({ load: function() { return hub.server.getAllData(); }, key: "Date" }); hub.client.updateStockPrice = function(data) { store.push([{ type: "insert", key: data.Date, data: data }]); }; $.connection.hub.start({ waitForPageLoad: false }).done(function() { $("#chart").dxChart({ dataSource: store, margin: { right: 30 }, title: "Stock Price", series: [{ argumentField: "Date", type: "candlestick", aggregation: { enabled: true, method: "custom", calculate: function(e) { var prices = e.data.map(function(i) { return i.Price; }); if (prices.length) { return { Date: e.intervalStart, open: prices[0], high: Math.max.apply(null, prices), low: Math.min.apply(null, prices), close: prices[prices.length - 1] }; } } } }], zoomAndPan: { argumentAxis: "both" }, scrollBar: { visible: true }, legend: { visible: false }, argumentAxis: { argumentType: "datetime", valueMarginsEnabled: false, visualRange: { length: "hour" } }, valueAxis: { placeholderSize: 50 }, onZoomEnd: function(e) { if (e.range.endValue - e.range.startValue < 1000 * 60 * 10) { e.cancel = true; } } }); }); });
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>DevExtreme Demo</title> <meta http-equiv="X-UA-Compatible" content="IE=edge" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0" /> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script> <script>window.jQuery || document.write(decodeURIComponent('%3Cscript src="js/jquery.min.js"%3E%3C/script%3E'))</script> <script src="js/signalr/jquery.signalR-2.2.2.js"></script> <script src="js/signalr/signalr-hub.js"></script> <link rel="stylesheet" type="text/css" href="https://cdn3.devexpress.com/jslib/18.2.3/css/dx.common.css" /> <link rel="dx-theme" data-theme="generic.light" href="https://cdn3.devexpress.com/jslib/18.2.3/css/dx.light.css" /> <script src="https://cdn3.devexpress.com/jslib/18.2.3/js/dx.all.js"></script> <link rel="stylesheet" type ="text/css" href ="styles.css" /> <script src="index.js"></script> </head> <body class="dx-viewport"> <div class="demo-container"> <div id="chart"></div> </div> </body> </html>
#chart{ height: 440px; }