Your search did not match any results.
Charts

SignalR Service

Documentation

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
var DemoApp = angular.module('DemoApp', ['dx']); DemoApp.controller('DemoController', function DemoController($scope) { var store = new DevExpress.data.CustomStore({ load: function() { return connection.invoke("getAllData"); }, key: "date" }); $scope.chartOptions = { dataSource: { store: store }, margin: { right: 30 }, loadingIndicator: { enabled: true }, 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, visualRangeUpdateMode: "auto", visualRange: { length: "hour" } }, valueAxis: { placeholderSize: 50 }, onZoomEnd: function(e) { if (e.range.endValue - e.range.startValue < 1000 * 60 * 10) { e.cancel = true; } } }; $scope.connectionStarted = false; var connection = new signalR.HubConnectionBuilder() .withUrl("https://js.devexpress.com/Demos/NetCore/stockTickDataHub") .configureLogging(signalR.LogLevel.Information) .build(); connection.start() .then(function () { connection.on("updateStockPrice", function (data) { store.push([{ type: "insert", key: data.date, data: data }]); }); $scope.connectionStarted = true; $scope.$apply(); }); });
<!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" /> <link rel="stylesheet" type="text/css" href="https://cdn3.devexpress.com/jslib/19.1.5/css/dx.common.css" /> <link rel="stylesheet" type="text/css" href="https://cdn3.devexpress.com/jslib/19.1.5/css/dx.light.css" /> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script> <script>window.jQuery || document.write(decodeURIComponent('%3Cscript src="js/jquery.min.js"%3E%3C/script%3E'))</script> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.16/angular.min.js"></script> <script>window.angular || document.write(decodeURIComponent('%3Cscript src="js/angular.min.js"%3E%3C\/script%3E'))</script> <script src="https://cdn3.devexpress.com/jslib/19.1.5/js/dx.all.js"></script> <script src="js/signalr/signalr-client.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" ng-app="DemoApp" ng-controller="DemoController"> <div ng-if="connectionStarted"> <div id="chart" dx-chart="chartOptions"></div> </div> </div> </body> </html>
#chart{ height: 440px; }