Git Product home page Git Product logo

aspnetcoresignalrcharts's Introduction

Real-time Charts with ASP.NET Core, SignalR, and Chart.js

chart example

This project shows how to update a real-time chart in your web browser using technologies like ASP.NET Core, SignalR, and Chart.js.

Note The backend is contrived using a Buffer type that is not thread-safe. Substitute your own implementation where data is derived from a database, web service, etc.

Getting Started

After installing the dotnet sdk, you can run the project.

dotnet run --project Charts -lp http

Then navigate to http://localhost:5296 if the browser did not open.

Thoughts

SignalR Setup

  • Setting up SignalR was relatively painless, but required some reading about what a Hub is and what a IHubContext<THub> is.
  • Using LibMan to manage JavaScript dependencies is nice. Check out libman.json in web project. There are several SignalR packages, so finding the right one was annoying.

Background Service

  • A background service is a nice approach to having a recurring event happen.

ASP.NET Core Razor Pages

  • I was able to do everything in Razor, but could have easily moved things to the IndexModel. By everything I mean injecting dependencies and generating the starting JSON for our Chart.JS element.
  • I ❤️ Razor Pages

Chart.Js

  • Relatively straightforward to set up and very responsive. The use of Canvas also allows for some interesting scenarios that I could explore later.
  • Getting data from the Razor Page/ASP.NET Core to ChartJs is an interesting challenge. I ended up using a script element with a type of application/json. Seems reasonable to me. The other choice was a global value on the window element.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.