Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
X
XChart
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Brady James Garvin
XChart
Commits
1d4022c7
Commit
1d4022c7
authored
11 years ago
by
Tim Molter
Browse files
Options
Downloads
Plain Diff
Merge pull request #37 from netomi/develop
Proposal to fix issue 36: area stack glitch.
parents
121d4c2a
0bf7b8df
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
xchart/src/main/java/com/xeiam/xchart/internal/chartpart/PlotContentLineChart.java
+33
-6
33 additions, 6 deletions
...xeiam/xchart/internal/chartpart/PlotContentLineChart.java
with
33 additions
and
6 deletions
xchart/src/main/java/com/xeiam/xchart/internal/chartpart/PlotContentLineChart.java
+
33
−
6
View file @
1d4022c7
...
...
@@ -107,6 +107,9 @@ public class PlotContentLineChart extends PlotContent {
if
(
errorBars
!=
null
)
{
ebItr
=
errorBars
.
iterator
();
}
Path2D
.
Double
path
=
null
;
while
(
xItr
.
hasNext
())
{
BigDecimal
x
=
null
;
...
...
@@ -124,6 +127,9 @@ public class PlotContentLineChart extends PlotContent {
Number
next
=
yItr
.
next
();
if
(
next
==
null
)
{
closePath
(
g
,
path
,
previousX
,
bounds
,
yTopMargin
);
path
=
null
;
previousX
=
Integer
.
MIN_VALUE
;
previousY
=
Integer
.
MIN_VALUE
;
continue
;
...
...
@@ -178,13 +184,19 @@ public class PlotContentLineChart extends PlotContent {
g
.
setColor
(
series
.
getStrokeColor
());
double
yBottomOfArea
=
bounds
.
getY
()
+
bounds
.
getHeight
()
-
yTopMargin
+
1
;
Path2D
.
Double
path
=
new
Path2D
.
Double
();
path
.
moveTo
(
previousX
,
previousY
);
// if the new x value is smaller than the previous one, close the current path
if
(
xOffset
<
previousX
)
{
closePath
(
g
,
path
,
previousX
,
bounds
,
yTopMargin
);
path
=
null
;
}
if
(
path
==
null
)
{
path
=
new
Path2D
.
Double
();
path
.
moveTo
(
previousX
,
yBottomOfArea
);
path
.
lineTo
(
previousX
,
previousY
);
}
path
.
lineTo
(
xOffset
,
yOffset
);
path
.
lineTo
(
xOffset
,
yBottomOfArea
);
path
.
lineTo
(
previousX
,
yBottomOfArea
);
path
.
closePath
();
g
.
fill
(
path
);
}
}
...
...
@@ -232,6 +244,21 @@ public class PlotContentLineChart extends PlotContent {
g
.
draw
(
line
);
}
}
// close any open path for area charts
closePath
(
g
,
path
,
previousX
,
bounds
,
yTopMargin
);
}
}
/**
* Closes a path for area charts if one is available.
*/
private
void
closePath
(
Graphics2D
g
,
Path2D
.
Double
path
,
double
previousX
,
Rectangle2D
bounds
,
double
yTopMargin
)
{
if
(
path
!=
null
)
{
double
yBottomOfArea
=
bounds
.
getY
()
+
bounds
.
getHeight
()
-
yTopMargin
+
1
;
path
.
lineTo
(
previousX
,
yBottomOfArea
);
path
.
closePath
();
g
.
fill
(
path
);
}
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment