Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
C
CurvedLines
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
CurvedLines
Commits
475c9a04
Commit
475c9a04
authored
Nov 17, 2011
by
Michael
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1 from paradoxxxzero/master
Add fill and fillColor options
parents
de933903
1bf85a4c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
7 deletions
+25
-7
curvedLines.js
curvedLines.js
+25
-7
No files found.
curvedLines.js
View file @
475c9a04
...
...
@@ -86,6 +86,8 @@ _____________________________________________________
var
options
=
{
series
:
{
curvedLines
:
{
active
:
false
,
show
:
false
,
fit
:
false
,
fill
:
false
,
fillColor
:
null
,
lineWidth
:
2
,
curvePointFactor
:
20
,
fitPointDist
:
0.0001
...
...
@@ -122,11 +124,17 @@ _____________________________________________________
ctx
.
translate
(
offset
.
left
,
offset
.
top
);
ctx
.
lineJoin
=
"round"
;
ctx
.
strokeStyle
=
series
.
color
;
ctx
.
lineWidth
=
series
.
curvedLines
.
lineWidth
;
if
(
series
.
curvedLines
.
fill
)
{
var
fillColor
=
series
.
curvedLines
.
fillColor
==
null
?
series
.
color
:
series
.
curvedLines
.
fillColor
;
var
c
=
$
.
color
.
parse
(
fillColor
);
c
.
a
=
typeof
fill
==
"number"
?
fill
:
0.4
;
c
.
normalize
();
ctx
.
fillStyle
=
c
.
toString
();
}
ctx
.
lineWidth
=
series
.
curvedLines
.
lineWidth
;
var
points
=
calculateCurvePoints
(
series
.
data
,
series
.
curvedLines
);
plotLine
(
ctx
,
points
,
axisx
,
axisy
);
plotLine
(
ctx
,
points
,
axisx
,
axisy
,
series
.
curvedLines
.
fill
);
ctx
.
restore
();
}
}
...
...
@@ -135,13 +143,14 @@ _____________________________________________________
//nearly the same as in the core library
//only ps is adjusted to 2
function
plotLine
(
ctx
,
points
,
axisx
,
axisy
)
{
function
plotLine
(
ctx
,
points
,
axisx
,
axisy
,
fill
)
{
var
ps
=
2
;
var
prevx
=
null
;
var
prevy
=
null
;
var
firsty
=
0
;
ctx
.
beginPath
();
ctx
.
beginPath
();
for
(
var
i
=
ps
;
i
<
points
.
length
;
i
+=
ps
)
{
var
x1
=
points
[
i
-
ps
],
y1
=
points
[
i
-
ps
+
1
];
...
...
@@ -208,12 +217,21 @@ _____________________________________________________
}
if
(
x1
!=
prevx
||
y1
!=
prevy
)
ctx
.
mov
eTo
(
axisx
.
p2c
(
x1
),
axisy
.
p2c
(
y1
));
ctx
.
lin
eTo
(
axisx
.
p2c
(
x1
),
axisy
.
p2c
(
y1
));
if
(
prevx
==
null
)
{
firsty
=
y2
;
}
prevx
=
x2
;
prevy
=
y2
;
ctx
.
lineTo
(
axisx
.
p2c
(
x2
),
axisy
.
p2c
(
y2
));
ctx
.
lineTo
(
axisx
.
p2c
(
x2
),
axisy
.
p2c
(
y2
));
}
if
(
fill
)
{
ctx
.
lineTo
(
axisx
.
p2c
(
axisx
.
max
),
axisy
.
p2c
(
axisy
.
min
));
ctx
.
lineTo
(
axisx
.
p2c
(
axisx
.
min
),
axisy
.
p2c
(
axisy
.
min
));
ctx
.
lineTo
(
axisx
.
p2c
(
axisx
.
min
),
axisy
.
p2c
(
firsty
));
ctx
.
fill
();
}
ctx
.
stroke
();
}
...
...
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