Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
c87a3766
Commit
c87a3766
authored
Dec 08, 2014
by
Sun He
Browse files
sparkline.c: mov label-ini into the AddSample Function
parent
93eed9ae
Changes
2
Show whitespace changes
Inline
Side-by-side
src/latency.c
View file @
c87a3766
...
...
@@ -475,7 +475,6 @@ sds latencyCommandGenSparkeline(char *event, struct latencyTimeSeries *ts) {
for
(
j
=
0
;
j
<
LATENCY_TS_LEN
;
j
++
)
{
int
i
=
(
ts
->
idx
+
j
)
%
LATENCY_TS_LEN
;
int
elapsed
;
char
*
label
;
char
buf
[
64
];
if
(
ts
->
samples
[
i
].
time
==
0
)
continue
;
...
...
@@ -497,8 +496,7 @@ sds latencyCommandGenSparkeline(char *event, struct latencyTimeSeries *ts) {
snprintf
(
buf
,
sizeof
(
buf
),
"%dh"
,
elapsed
/
3600
);
else
snprintf
(
buf
,
sizeof
(
buf
),
"%dd"
,
elapsed
/
(
3600
*
24
));
label
=
zstrdup
(
buf
);
sparklineSequenceAddSample
(
seq
,
ts
->
samples
[
i
].
latency
,
label
);
sparklineSequenceAddSample
(
seq
,
ts
->
samples
[
i
].
latency
,
buf
);
}
graph
=
sdscatprintf
(
graph
,
...
...
src/sparkline.c
View file @
c87a3766
...
...
@@ -49,7 +49,7 @@ static int label_margin_top = 1;
* sparklineSequenceAddSample(seq, 10, NULL);
* sparklineSequenceAddSample(seq, 20, NULL);
* sparklineSequenceAddSample(seq, 30, "last sample label");
* sds output = sparklineRender(s
eq, 80, 4
);
* sds output = sparklineRender(s
dsempty(), seq, 80, 4, SPARKLINE_FILL
);
* freeSparklineSequence(seq);
* ------------------------------------------------------------------------- */
...
...
@@ -63,6 +63,7 @@ struct sequence *createSparklineSequence(void) {
/* Add a new sample into a sequence. */
void
sparklineSequenceAddSample
(
struct
sequence
*
seq
,
double
value
,
char
*
label
)
{
label
=
label
==
NULL
?
label
:
zstrdup
(
label
);
if
(
seq
->
length
==
0
)
{
seq
->
min
=
seq
->
max
=
value
;
}
else
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment