30
30
#import " HWMonitorDefinitions.h"
31
31
#import " Localizer.h"
32
32
33
+ static NSMutableDictionary *graphs_history = nil ;
34
+
33
35
@implementation GraphsView
34
36
35
37
#define LeftViewMargin 1
36
38
#define TopViewMargin 1
37
39
#define RightViewMargin 1
38
40
#define BottomViewMargin 1
39
41
42
+ -(NSMutableDictionary *)graphs
43
+ {
44
+ if (!graphs_history) {
45
+ graphs_history = [[NSMutableDictionary alloc ] init ];
46
+ }
47
+
48
+ return graphs_history;
49
+ }
50
+
40
51
-(id )init
41
52
{
42
53
self = [super init ];
@@ -92,17 +103,12 @@ - (NSArray*)addItemsFromList:(NSArray*)itemsList forSensorGroup:(HWSensorGroup)s
92
103
else {
93
104
[_items removeAllObjects ];
94
105
}
95
-
96
- if (!_graphs) {
97
- _graphs = [[NSMutableDictionary alloc ] init ];
98
- }
99
- else {
100
- [_graphs removeAllObjects ];
101
- }
102
106
103
107
for (HWMonitorItem *item in itemsList) {
104
108
[_items addObject: item];
105
- [_graphs setObject: [[NSMutableArray alloc ] init ] forKey: [[item sensor ] name ]];
109
+ if (![self .graphs objectForKey: item.sensor.name]) {
110
+ [self .graphs setObject: [[NSMutableArray alloc ] init ] forKey: [[item sensor ] name ]];
111
+ }
106
112
}
107
113
108
114
[self calculateGraphBoundsFindExtremes: YES ];
@@ -114,7 +120,7 @@ - (void)captureDataToHistoryNow;
114
120
{
115
121
for (HWMonitorItem *item in _items) {
116
122
HWMonitorSensor *sensor = [item sensor ];
117
- NSMutableArray *history = [_graphs objectForKey: [sensor name ]];
123
+ NSMutableArray *history = [self .graphs objectForKey: [sensor name ]];
118
124
119
125
if ([sensor rawValue ]) {
120
126
[history addObject: [sensor rawValue ]];
@@ -142,7 +148,7 @@ - (void)calculateGraphBoundsFindExtremes:(BOOL)findExtremes
142
148
continue ;
143
149
144
150
HWMonitorSensor *sensor = [item sensor ];
145
- NSArray *points = [_graphs objectForKey: [sensor name ]];
151
+ NSArray *points = [self .graphs objectForKey: [sensor name ]];
146
152
147
153
if (points) {
148
154
for (NSNumber *point in points) {
@@ -235,7 +241,7 @@ - (void)drawRect:(NSRect)rect
235
241
continue ;
236
242
237
243
HWMonitorSensor *sensor = [item sensor ];
238
- NSArray *values = [_graphs objectForKey: [sensor name ]];
244
+ NSArray *values = [self .graphs objectForKey: [sensor name ]];
239
245
240
246
if (!values || [values count ] < 2 )
241
247
continue ;
0 commit comments