Skip to content

Commit

Permalink
Fix for break in scaling for some charts
Browse files Browse the repository at this point in the history
  • Loading branch information
nkaraman authored and Mykola Karaman committed Oct 9, 2017
1 parent 7d791fd commit cfaa2dd
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -915,11 +915,9 @@ public void add(int index, DataSource source, boolean visible) {
throw new IllegalArgumentException(
"This plot type only supports a single data source."); //$NON-NLS-1$
}

super.add(index, source, visible);
PointRenderer pointRendererDefault = new PieSliceRenderer(this);
setPointRenderer(source, pointRendererDefault);

super.add(index, source, visible);
setMapping(source, AXIS_TANGENTIAL);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,9 @@ public double worldToView(Axis axis, Number value, boolean extrapolate) {
}
double minLog = (min > 0.0) ? Math.log10(min) : 0.0;
double maxLog = (max > 0.0) ? Math.log10(max) : 1.0;
return (Math.log10(val) - minLog)*getShapeLength() /
double result = (Math.log10(val) - minLog)*getShapeLength() /
(maxLog - minLog);
return Double.isFinite(result) ? result : 0;
}

/**
Expand All @@ -92,8 +93,9 @@ public Number viewToWorld(Axis axis, double value, boolean extrapolate) {
}
double minLog = (min > 0.0) ? Math.log10(min) : 0.0;
double maxLog = (max > 0.0) ? Math.log10(max) : 1.0;
return Math.pow(10.0,
double result = Math.pow(10.0,
value*(maxLog - minLog)/getShapeLength() + minLog);
return Double.isFinite(result) ? result : 0;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public void testDraw() {

@Test
public void testWorldToView() {
assertEquals(Double.NEGATIVE_INFINITY, renderer.worldToView(axis, 0.0, true), DELTA);
assertEquals(0, renderer.worldToView(axis, 0.0, true), DELTA);
assertEquals(Math.log10( 0.1), renderer.worldToView(axis, 0.1, true), DELTA);
assertEquals(Math.log10( 1.0), renderer.worldToView(axis, 1.0, true), DELTA);
assertEquals(Math.log10( 5.0), renderer.worldToView(axis, 5.0, true), DELTA);
Expand Down

0 comments on commit cfaa2dd

Please sign in to comment.