File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -83,3 +83,8 @@ TextBlock* AdafruitIO_Dashboard::addTextBlock(AdafruitIO_Feed *feed)
8383{
8484 return new TextBlock (this , feed);
8585}
86+
87+ ChartBlock* AdafruitIO_Dashboard::addChartBlock (AdafruitIO_Feed *feed)
88+ {
89+ return new ChartBlock (this , feed);
90+ }
Original file line number Diff line number Diff line change 1919#include " blocks/SliderBlock.h"
2020#include " blocks/GaugeBlock.h"
2121#include " blocks/TextBlock.h"
22+ #include " blocks/ChartBlock.h"
2223
2324// forward declaration
2425class AdafruitIO ;
@@ -40,6 +41,7 @@ class AdafruitIO_Dashboard {
4041 SliderBlock* addSliderBlock (AdafruitIO_Feed *feed);
4142 GaugeBlock* addGaugeBlock (AdafruitIO_Feed *feed);
4243 TextBlock* addTextBlock (AdafruitIO_Feed *feed);
44+ ChartBlock* addChartBlock (AdafruitIO_Feed *feed);
4345
4446 private:
4547 AdafruitIO *_io;
Original file line number Diff line number Diff line change 1+ //
2+ // Adafruit invests time and resources providing this open source code.
3+ // Please support Adafruit and open source hardware by purchasing
4+ // products from Adafruit!
5+ //
6+ // Copyright (c) 2015-2016 Adafruit Industries
7+ // Authors: Tony DiCola, Todd Treece
8+ // Licensed under the MIT license.
9+ //
10+ // All text above must be included in any redistribution.
11+ //
12+ #include " ChartBlock.h"
13+
14+ ChartBlock::ChartBlock (AdafruitIO_Dashboard *d, AdafruitIO_Feed *f) : AdafruitIO_Block(d, f)
15+ {
16+ historyHours = 0 ;
17+ xAxisLabel = " X" ;
18+ yAxisLabel = " Y" ;
19+ yAxisMin = 0 ;
20+ yAxisMax = 100 ;
21+ }
22+
23+ ChartBlock::~ChartBlock (){}
24+
25+ String ChartBlock::properties ()
26+ {
27+
28+ String props = " {\" historyHours\" :\" " ;
29+ props += historyHours;
30+ props += " \" ,\" xAxisLabel\" :" ;
31+ props += xAxisLabel;
32+ props += " \" ,\" yAxisLabel\" :" ;
33+ props += yAxisLabel;
34+ props += " \" ,\" yAxisMin\" :" ;
35+ props += yAxisMin;
36+ props += " \" ,\" yAxisMax\" :" ;
37+ props += yAxisMax;
38+ props += " \" }" ;
39+
40+ return props;
41+ }
Original file line number Diff line number Diff line change 1+ //
2+ // Adafruit invests time and resources providing this open source code.
3+ // Please support Adafruit and open source hardware by purchasing
4+ // products from Adafruit!
5+ //
6+ // Copyright (c) 2015-2016 Adafruit Industries
7+ // Authors: Tony DiCola, Todd Treece
8+ // Licensed under the MIT license.
9+ //
10+ // All text above must be included in any redistribution.
11+ //
12+ #ifndef ADAFRUITIO_CHARTBLOCK_H
13+ #define ADAFRUITIO_CHARTBLOCK_H
14+
15+ #include " AdafruitIO_Block.h"
16+
17+ class ChartBlock : public AdafruitIO_Block {
18+
19+ public:
20+ ChartBlock (AdafruitIO_Dashboard *d, AdafruitIO_Feed *f);
21+ ~ChartBlock ();
22+
23+ int historyHours;
24+ const char *xAxisLabel;
25+ const char *yAxisLabel;
26+ int yAxisMin;
27+ int yAxisMax;
28+
29+ String properties ();
30+
31+ private:
32+ const char *_visual_type = " line_chart" ;
33+
34+ };
35+
36+ #endif // ADAFRUITIO_CHARTBLOCK_H
You can’t perform that action at this time.
0 commit comments