Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
F
flot
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
HS-public
flot
Commits
2f7cfcb5
Commit
2f7cfcb5
authored
Nov 22, 2012
by
David Schnur
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #878 from dnschnur/tick-decimals-fix
Fix tickDecimals option broken by pull #50.
parents
db83cd0c
0e993605
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
4 deletions
+19
-4
setting-options.html
examples/setting-options.html
+2
-1
jquery.flot.js
jquery.flot.js
+17
-3
No files found.
examples/setting-options.html
View file @
2f7cfcb5
...
@@ -48,7 +48,8 @@ $(function () {
...
@@ -48,7 +48,8 @@ $(function () {
yaxis
:
{
yaxis
:
{
ticks
:
10
,
ticks
:
10
,
min
:
-
2
,
min
:
-
2
,
max
:
2
max
:
2
,
tickDecimals
:
3
},
},
grid
:
{
grid
:
{
backgroundColor
:
{
colors
:
[
"#fff"
,
"#eee"
]
}
backgroundColor
:
{
colors
:
[
"#fff"
,
"#eee"
]
}
...
...
jquery.flot.js
View file @
2f7cfcb5
...
@@ -1290,9 +1290,23 @@
...
@@ -1290,9 +1290,23 @@
return
ticks
;
return
ticks
;
};
};
axis
.
tickFormatter
=
function
(
v
,
axis
)
{
axis
.
tickFormatter
=
function
(
value
,
axis
)
{
var
factor
=
Math
.
pow
(
10
,
axis
.
tickDecimals
);
return
""
+
Math
.
round
(
v
*
factor
)
/
factor
;
var
factor
=
Math
.
pow
(
10
,
axis
.
tickDecimals
);
var
formatted
=
""
+
Math
.
round
(
value
*
factor
)
/
factor
;
// If tickDecimals was specified, ensure that we have exactly that
// much precision; otherwise default to the value's own precision.
if
(
axis
.
tickDecimals
!=
null
)
{
var
decimal
=
formatted
.
indexOf
(
"."
);
var
precision
=
decimal
==
-
1
?
0
:
formatted
.
length
-
decimal
-
1
;
if
(
precision
<
axis
.
tickDecimals
)
{
return
(
precision
?
formatted
:
formatted
+
"."
)
+
(
""
+
factor
).
substr
(
1
,
axis
.
tickDecimals
-
precision
);
}
}
return
formatted
;
};
};
}
}
...
...
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