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
c14eaf45
Commit
c14eaf45
authored
Nov 05, 2013
by
Anthony Ryan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
CSP compatibility for flot legend
parent
9671e73d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
24 deletions
+36
-24
jquery.flot.js
jquery.flot.js
+36
-24
No files found.
jquery.flot.js
View file @
c14eaf45
...
@@ -2928,7 +2928,7 @@ Licensed under the MIT license.
...
@@ -2928,7 +2928,7 @@ Licensed under the MIT license.
return
;
return
;
}
}
var
fragments
=
[],
entries
=
[],
rowStarted
=
false
,
var
entries
=
[],
rowBuffer
=
null
,
lf
=
options
.
legend
.
labelFormatter
,
s
,
label
,
i
;
lf
=
options
.
legend
.
labelFormatter
,
s
,
label
,
i
;
// Build a list of legend entries, with each having a label and a color
// Build a list of legend entries, with each having a label and a color
...
@@ -2946,6 +2946,12 @@ Licensed under the MIT license.
...
@@ -2946,6 +2946,12 @@ Licensed under the MIT license.
}
}
}
}
// No entries implies no legend
if
(
entries
.
length
===
0
)
{
return
;
}
// Sort the legend using either the default or a custom comparator
// Sort the legend using either the default or a custom comparator
if
(
options
.
legend
.
sorted
)
{
if
(
options
.
legend
.
sorted
)
{
...
@@ -2965,53 +2971,52 @@ Licensed under the MIT license.
...
@@ -2965,53 +2971,52 @@ Licensed under the MIT license.
// Generate markup for the list of entries, in their final order
// Generate markup for the list of entries, in their final order
var
table
=
$
(
"<table/>"
).
css
({
"font-size"
:
"smaller"
,
"color"
:
options
.
grid
.
color
});
for
(
i
=
0
;
i
<
entries
.
length
;
++
i
)
{
for
(
i
=
0
;
i
<
entries
.
length
;
++
i
)
{
var
entry
=
entries
[
i
];
var
entry
=
entries
[
i
];
if
(
i
%
options
.
legend
.
noColumns
===
0
)
{
if
(
i
%
options
.
legend
.
noColumns
===
0
)
{
if
(
row
Started
)
{
if
(
row
Buffer
!==
null
)
{
fragments
.
push
(
"</tr>"
);
table
.
append
(
rowBuffer
);
}
}
fragments
.
push
(
"<tr>"
);
rowBuffer
=
$
(
"<tr/>"
);
rowStarted
=
true
;
}
}
fragments
.
push
(
rowBuffer
.
append
(
"<td class='legendColorBox'><div style='border:1px solid "
+
options
.
legend
.
labelBoxBorderColor
+
";padding:1px'><div style='width:4px;height:0;border:5px solid "
+
entry
.
color
+
";overflow:hidden'></div></div></td>"
+
$
(
"<td/>"
).
addClass
(
"legendColorBox"
).
append
(
"<td class='legendLabel'>"
+
entry
.
label
+
"</td>"
$
(
"<div/>"
).
css
({
"border"
:
"1px solid "
+
options
.
legend
.
labelBoxBorderColor
,
"padding"
:
"1px"
}).
append
(
$
(
"<div/>"
).
css
({
"width"
:
"4px"
,
"height"
:
0
,
"border"
:
"5px solid "
+
entry
.
color
,
"overflow"
:
"hidden"
})
)
),
$
(
"<td/>"
).
addClass
(
"legendLabel"
).
html
(
entry
.
label
)
);
);
}
}
if
(
rowStarted
)
{
fragments
.
push
(
"</tr>"
);
}
if
(
fragments
.
length
===
0
)
{
return
;
}
var
table
=
"<table style='font-size:smaller;color:"
+
options
.
grid
.
color
+
"'>"
+
fragments
.
join
(
""
)
+
"</table>"
;
if
(
options
.
legend
.
container
!=
null
)
{
if
(
options
.
legend
.
container
!=
null
)
{
$
(
options
.
legend
.
container
).
html
(
table
);
$
(
options
.
legend
.
container
).
html
(
table
);
}
else
{
}
else
{
var
pos
=
""
,
var
pos
=
{
"position"
:
"absolute"
}
,
p
=
options
.
legend
.
position
,
p
=
options
.
legend
.
position
,
m
=
options
.
legend
.
margin
;
m
=
options
.
legend
.
margin
;
if
(
m
[
0
]
==
null
)
{
if
(
m
[
0
]
==
null
)
{
m
=
[
m
,
m
];
m
=
[
m
,
m
];
}
}
if
(
p
.
charAt
(
0
)
===
"n"
)
{
if
(
p
.
charAt
(
0
)
===
"n"
)
{
pos
+=
"top:"
+
(
m
[
1
]
+
plotOffset
.
top
)
+
"px;
"
;
pos
.
top
=
(
m
[
1
]
+
plotOffset
.
top
)
+
"px
"
;
}
else
if
(
p
.
charAt
(
0
)
===
"s"
)
{
}
else
if
(
p
.
charAt
(
0
)
===
"s"
)
{
pos
+=
"bottom:"
+
(
m
[
1
]
+
plotOffset
.
bottom
)
+
"px;
"
;
pos
.
bottom
=
(
m
[
1
]
+
plotOffset
.
bottom
)
+
"px
"
;
}
}
if
(
p
.
charAt
(
1
)
===
"e"
)
{
if
(
p
.
charAt
(
1
)
===
"e"
)
{
pos
+=
"right:"
+
(
m
[
0
]
+
plotOffset
.
right
)
+
"px;
"
;
pos
.
right
=
(
m
[
0
]
+
plotOffset
.
right
)
+
"px
"
;
}
else
if
(
p
.
charAt
(
1
)
===
"w"
)
{
}
else
if
(
p
.
charAt
(
1
)
===
"w"
)
{
pos
+=
"left:"
+
(
m
[
0
]
+
plotOffset
.
left
)
+
"px;
"
;
pos
.
left
=
(
m
[
0
]
+
plotOffset
.
left
)
+
"px
"
;
}
}
var
legend
=
$
(
"<div
class='legend'>"
+
table
.
replace
(
"style='"
,
"style='position:absolute;"
+
pos
+
";"
)
+
"</div>"
).
appendTo
(
placeholder
);
var
legend
=
$
(
"<div
/>"
).
addClass
(
"legend"
).
append
(
table
.
css
(
pos
)
).
appendTo
(
placeholder
);
if
(
options
.
legend
.
backgroundOpacity
!==
0.0
)
{
if
(
options
.
legend
.
backgroundOpacity
!==
0.0
)
{
// put in the transparent background
// put in the transparent background
// separately to avoid blended labels and
// separately to avoid blended labels and
...
@@ -3028,7 +3033,14 @@ Licensed under the MIT license.
...
@@ -3028,7 +3033,14 @@ Licensed under the MIT license.
c
=
c
.
toString
();
c
=
c
.
toString
();
}
}
var
div
=
legend
.
children
();
var
div
=
legend
.
children
();
$
(
"<div style='position:absolute;width:"
+
div
.
width
()
+
"px;height:"
+
div
.
height
()
+
"px;"
+
pos
+
"background-color:"
+
c
+
";'> </div>"
).
prependTo
(
legend
).
css
(
"opacity"
,
options
.
legend
.
backgroundOpacity
);
// Position also applies to this
$
(
"<div/>"
).
css
(
pos
).
css
({
"width"
:
div
.
width
()
+
"px"
,
"height"
:
div
.
height
()
+
"px"
,
"background-color"
:
c
,
"opacity"
:
options
.
legend
.
backgroundOpacity
}).
prependTo
(
legend
);
}
}
}
}
}
}
...
...
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