Fireship · @fireship

Realtime Graphs and Charts with Plotly and Firebase

Uploaded August 11, 2017 · Length 5:56

Realtime Graphs and Charts with Plotly and Firebase

Summary

Combine Plotly and Firebase to create real-time charts and graphs, including 2D line charts, 3D topographical charts, and interactive Turner charts.

  • plotly and firebase
  • realtime charts
  • data visualization
  • angular and firebase
  • javascript library
  • charting library

Transcript preview

The first 2 minutes of the transcript. Select a timestamp to watch that moment on YouTube.

  1. 0:00

    in the age of big data and deep learning

  2. 0:02

    data visualization is an extremely

  3. 0:04

    important tool for many applications in

  4. 0:06

    this episode we're going to combine the

  5. 0:08

    plotly JS Library along with angular and

  6. 0:11

    Firebase to create three different types

  7. 0:13

    of charts that are capable of handling

  8. 0:15

    real-time data we'll start by building a

  9. 0:17

    basic 2D line chart and then we'll build

  10. 0:20

    up to a 3D topographical chart then

  11. 0:22

    we'll finish up with a tary chart that's

  12. 0:25

    capable of staying in sync with the

  13. 0:26

    real-time back end on Firebase the first

  14. 0:29

    step is to to install the plotly JS

  15. 0:31

    Library which we can do with npm install

  16. 0:33

    plotly.js flag saave then add it to the

  17. 0:37

    script section in the

  18. 0:39

    angular-cli Json file it's worth noting

  19. 0:42

    that plot Le is a pretty big Library so

  20. 0:44

    if you want to slim it down a little bit

  21. 0:46

    go to your node modules and find just

  22. 0:48

    the script that you need for your app in

  23. 0:50

    this case we're using the entire Library

  24. 0:52

    which is probably overkill for most

  25. 0:54

    situations then in your typing. D file

  26. 0:57

    add the plotly class so it's recognized

  27. 0:59

    by typescript

  28. 1:00

    now we can start building our first line

  29. 1:02

    chart this chart will just be completely

  30. 1:04

    static just to show you the general

  31. 1:06

    concepts behind plotly in the HTML

  32. 1:09

    create an empty div and then give it a

  33. 1:10

    template reference variable named chart

  34. 1:13

    then in the component typescript we'll

  35. 1:14

    use viewchild as well as element ref

  36. 1:17

    then we're going to build this chart

  37. 1:18

    service in The Next Step once we start

  38. 1:20

    using live data from Firebase so you can

  39. 1:22

    ignore that for now and we'll also use

  40. 1:25

    the low Dash Library so to get a hold of

  41. 1:28

    the div in the HTML we use viewchild and

  42. 1:30

    then reference that chart variable that

  43. 1:32

    we Nam there then we'll name it l in the

  44. 1:35

    typescript which is more or less an

  45. 1:36

    angular convention then to actually

  46. 1:39

    build a plotly chart there are three

  47. 1:41

    basic variables that you need to be

  48. 1:42

    aware of first we have element which is

  49. 1:45

    the HTML element that will be replaced

  50. 1:48

    by the chart and then we have data

  51. 1:50

    that's the actual data that's going to

  52. 1:51

    be displayed in the chart here we have a

  53. 1:53

    few numbers on the X and Y axis that

  54. 1:55

    will create a basic line chart with a

  55. 1:57

    curve the third variable is style which

  56. 1:59

    defines the style options that vary from