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
e7634c64
Commit
e7634c64
authored
May 04, 2012
by
David Schnur
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #5 from smashedpumpkin/fix-issue-520
Added a 'right' option for bar alignment.
parents
ad02cfbe
40d886f9
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
7 deletions
+38
-7
API.txt
API.txt
+4
-4
jquery.flot.js
jquery.flot.js
+34
-3
No files found.
API.txt
View file @
e7634c64
...
@@ -564,7 +564,7 @@ Customizing the data series
...
@@ -564,7 +564,7 @@ Customizing the data series
bars: {
bars: {
barWidth: number
barWidth: number
align: "left" or "center"
align: "left"
, "right"
or "center"
horizontal: boolean
horizontal: boolean
}
}
...
@@ -615,9 +615,9 @@ the y axis if "horizontal" is true), contrary to most other measures
...
@@ -615,9 +615,9 @@ the y axis if "horizontal" is true), contrary to most other measures
that are specified in pixels. For instance, for time series the unit
that are specified in pixels. For instance, for time series the unit
is milliseconds so 24 * 60 * 60 * 1000 produces bars with the width of
is milliseconds so 24 * 60 * 60 * 1000 produces bars with the width of
a day. "align" specifies whether a bar should be left-aligned
a day. "align" specifies whether a bar should be left-aligned
(default)
or centered on top of the value it represents. When
(default)
, right-aligned or centered on top of the value it represents.
"horizontal" is on, the bars are drawn horizontally, i.e. from the y
When "horizontal" is on, the bars are drawn horizontally, i.e. from the
axis instead of the x axis; note that the bar end points are still
y
axis instead of the x axis; note that the bar end points are still
defined in the same way so you'll probably want to swap the
defined in the same way so you'll probably want to swap the
coordinates if you've been plotting vertical bars first.
coordinates if you've been plotting vertical bars first.
...
...
jquery.flot.js
View file @
e7634c64
...
@@ -110,7 +110,7 @@
...
@@ -110,7 +110,7 @@
barWidth
:
1
,
// in units of the x axis
barWidth
:
1
,
// in units of the x axis
fill
:
true
,
fill
:
true
,
fillColor
:
null
,
fillColor
:
null
,
align
:
"left"
,
//
or "center"
align
:
"left"
,
//
"left", "right", or "center"
horizontal
:
false
horizontal
:
false
},
},
shadowSize
:
3
shadowSize
:
3
...
@@ -668,7 +668,22 @@
...
@@ -668,7 +668,22 @@
if
(
s
.
bars
.
show
)
{
if
(
s
.
bars
.
show
)
{
// make sure we got room for the bar on the dancing floor
// make sure we got room for the bar on the dancing floor
var
delta
=
s
.
bars
.
align
==
"left"
?
0
:
-
s
.
bars
.
barWidth
/
2
;
var
delta
;
switch
(
s
.
bars
.
align
)
{
case
'left'
:
delta
=
0
;
break
;
case
'right'
:
delta
=
-
s
.
bars
.
barWidth
;
break
;
case
'center'
:
delta
=
-
s
.
bars
.
barWidth
/
2
;
break
;
default
:
throw
'Invalid bar alignment: '
+
s
.
bars
.
align
;
}
if
(
s
.
bars
.
horizontal
)
{
if
(
s
.
bars
.
horizontal
)
{
ymin
+=
delta
;
ymin
+=
delta
;
ymax
+=
delta
+
s
.
bars
.
barWidth
;
ymax
+=
delta
+
s
.
bars
.
barWidth
;
...
@@ -2210,7 +2225,23 @@
...
@@ -2210,7 +2225,23 @@
// FIXME: figure out a way to add shadows (for instance along the right edge)
// FIXME: figure out a way to add shadows (for instance along the right edge)
ctx
.
lineWidth
=
series
.
bars
.
lineWidth
;
ctx
.
lineWidth
=
series
.
bars
.
lineWidth
;
ctx
.
strokeStyle
=
series
.
color
;
ctx
.
strokeStyle
=
series
.
color
;
var
barLeft
=
series
.
bars
.
align
==
"left"
?
0
:
-
series
.
bars
.
barWidth
/
2
;
var
barLeft
;
switch
(
series
.
bars
.
align
)
{
case
'left'
:
barLeft
=
0
;
break
;
case
'right'
:
barLeft
=
-
series
.
bars
.
barWidth
;
break
;
case
'center'
:
barLeft
=
-
series
.
bars
.
barWidth
/
2
;
break
;
default
:
throw
'Invalid bar alignment: '
+
series
.
bars
.
align
;
}
var
fillStyleCallback
=
series
.
bars
.
fill
?
function
(
bottom
,
top
)
{
return
getFillStyle
(
series
.
bars
,
series
.
color
,
bottom
,
top
);
}
:
null
;
var
fillStyleCallback
=
series
.
bars
.
fill
?
function
(
bottom
,
top
)
{
return
getFillStyle
(
series
.
bars
,
series
.
color
,
bottom
,
top
);
}
:
null
;
plotBars
(
series
.
datapoints
,
barLeft
,
barLeft
+
series
.
bars
.
barWidth
,
0
,
fillStyleCallback
,
series
.
xaxis
,
series
.
yaxis
);
plotBars
(
series
.
datapoints
,
barLeft
,
barLeft
+
series
.
bars
.
barWidth
,
0
,
fillStyleCallback
,
series
.
xaxis
,
series
.
yaxis
);
ctx
.
restore
();
ctx
.
restore
();
...
...
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