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
0bf7b8df
Commit
0bf7b8df
authored
11 years ago
by
Thomas Neidhart
Browse files
Options
Downloads
Patches
Plain Diff
Proposal to fix issue 36: area stack glitch.
parent
121d4c2a
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 @
0bf7b8df
...
@@ -107,6 +107,9 @@ public class PlotContentLineChart extends PlotContent {
...
@@ -107,6 +107,9 @@ public class PlotContentLineChart extends PlotContent {
if
(
errorBars
!=
null
)
{
if
(
errorBars
!=
null
)
{
ebItr
=
errorBars
.
iterator
();
ebItr
=
errorBars
.
iterator
();
}
}
Path2D
.
Double
path
=
null
;
while
(
xItr
.
hasNext
())
{
while
(
xItr
.
hasNext
())
{
BigDecimal
x
=
null
;
BigDecimal
x
=
null
;
...
@@ -124,6 +127,9 @@ public class PlotContentLineChart extends PlotContent {
...
@@ -124,6 +127,9 @@ public class PlotContentLineChart extends PlotContent {
Number
next
=
yItr
.
next
();
Number
next
=
yItr
.
next
();
if
(
next
==
null
)
{
if
(
next
==
null
)
{
closePath
(
g
,
path
,
previousX
,
bounds
,
yTopMargin
);
path
=
null
;
previousX
=
Integer
.
MIN_VALUE
;
previousX
=
Integer
.
MIN_VALUE
;
previousY
=
Integer
.
MIN_VALUE
;
previousY
=
Integer
.
MIN_VALUE
;
continue
;
continue
;
...
@@ -178,13 +184,19 @@ public class PlotContentLineChart extends PlotContent {
...
@@ -178,13 +184,19 @@ public class PlotContentLineChart extends PlotContent {
g
.
setColor
(
series
.
getStrokeColor
());
g
.
setColor
(
series
.
getStrokeColor
());
double
yBottomOfArea
=
bounds
.
getY
()
+
bounds
.
getHeight
()
-
yTopMargin
+
1
;
double
yBottomOfArea
=
bounds
.
getY
()
+
bounds
.
getHeight
()
-
yTopMargin
+
1
;
Path2D
.
Double
path
=
new
Path2D
.
Double
();
// if the new x value is smaller than the previous one, close the current path
path
.
moveTo
(
previousX
,
previousY
);
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
,
yOffset
);
path
.
lineTo
(
xOffset
,
yBottomOfArea
);
path
.
lineTo
(
previousX
,
yBottomOfArea
);
path
.
closePath
();
g
.
fill
(
path
);
}
}
}
}
...
@@ -232,6 +244,21 @@ public class PlotContentLineChart extends PlotContent {
...
@@ -232,6 +244,21 @@ public class PlotContentLineChart extends PlotContent {
g
.
draw
(
line
);
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