Skip to content
Snippets Groups Projects
Commit 2f76d5ac authored by Tim Molter's avatar Tim Molter
Browse files

unit tests, pulled out grid step calculations, working towards bar charts and logarithmic axes

parent a54fb8ef
No related branches found
No related tags found
No related merge requests found
Showing
with 218 additions and 231 deletions
......@@ -17,9 +17,9 @@ package com.xeiam.xchart.demo.charts.area;
import com.xeiam.xchart.Chart;
import com.xeiam.xchart.ChartBuilder;
import com.xeiam.xchart.ChartBuilder.ChartType;
import com.xeiam.xchart.SwingWrapper;
import com.xeiam.xchart.demo.charts.line.ExampleChart;
import com.xeiam.xchart.style.StyleManager.ChartType;
import com.xeiam.xchart.style.StyleManager.LegendPosition;
/**
......@@ -40,7 +40,7 @@ public class AreaChart01 implements ExampleChart {
public Chart getChart() {
// Create Chart
Chart chart = new ChartBuilder().chartType(ChartType.Area).width(800).height(600).title("LineChart11").xAxisTitle("X").yAxisTitle("Y").build();
Chart chart = new ChartBuilder().chartType(ChartType.Area).width(800).height(600).title("AreaChart01").xAxisTitle("X").yAxisTitle("Y").build();
chart.addSeries("a", new double[] { 0, 3, 5, 7, 9 }, new double[] { -3, 5, 9, 6, 5 });
chart.addSeries("b", new double[] { 0, 2, 4, 6, 9 }, new double[] { -1, 6, 4, 0, 4 });
chart.addSeries("c", new double[] { 0, 1, 3, 8, 9 }, new double[] { -2, -1, 1, 0, 1 });
......
......@@ -19,34 +19,38 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.xeiam.xchart;
package com.xeiam.xchart.demo.charts.bar;
import com.xeiam.xchart.Chart;
import com.xeiam.xchart.ChartBuilder;
import com.xeiam.xchart.SwingWrapper;
import com.xeiam.xchart.demo.charts.line.ExampleChart;
import com.xeiam.xchart.style.StyleManager.ChartType;
import com.xeiam.xchart.style.StyleManager.LegendPosition;
/**
* A Scatter Chart is a contains series with no lines drawn between the points
*
* @author timmolter
*/
public class LineChart extends Chart {
/**
* Constructor
*
* @param width
* @param height
*/
public LineChart(int width, int height) {
public class BarChart01 implements ExampleChart {
super(width, height);
public static void main(String[] args) {
ExampleChart exampleChart = new BarChart01();
Chart chart = exampleChart.getChart();
new SwingWrapper(chart).displayChart();
}
/**
* Constructor
*
* @param chartBuilder
*/
public LineChart(ChartBuilder chartBuilder) {
@Override
public Chart getChart() {
// Create Chart
Chart chart = new ChartBuilder().chartType(ChartType.Bar).width(800).height(600).title("BarChart01").xAxisTitle("X").yAxisTitle("Y").build();
chart.addSeries("a", new double[] { 0, 1, 2, 3, 4 }, new double[] { -3, 5, 9, 6, 5 });
// Customize Chart
chart.getStyleManager().setChartTitleVisible(false);
chart.getStyleManager().setLegendPosition(LegendPosition.InsideNW);
super(chartBuilder);
return chart;
}
}
......@@ -19,7 +19,6 @@ import java.util.Arrays;
import java.util.Collection;
import com.xeiam.xchart.Chart;
import com.xeiam.xchart.LineChart;
import com.xeiam.xchart.SwingWrapper;
import com.xeiam.xchart.style.Series;
import com.xeiam.xchart.style.SeriesMarker;
......@@ -79,7 +78,7 @@ public class LineChart01 implements ExampleChart {
Collection<Number> yData = Arrays.asList(yDataArray);
// Create Chart
Chart chart = new LineChart(800, 600);
Chart chart = new Chart(800, 600);
// Customize Chart
chart.setChartTitle("LineChart01");
......
......@@ -19,7 +19,6 @@ import java.util.ArrayList;
import java.util.List;
import com.xeiam.xchart.Chart;
import com.xeiam.xchart.LineChart;
import com.xeiam.xchart.SwingWrapper;
import com.xeiam.xchart.style.Series;
import com.xeiam.xchart.style.SeriesColor;
......@@ -57,7 +56,7 @@ public class LineChart02 implements ExampleChart {
}
// Create Chart
Chart chart = new LineChart(800, 600);
Chart chart = new Chart(800, 600);
// Customize Chart
chart.getStyleManager().setChartTitleVisible(false);
......
......@@ -19,7 +19,6 @@ import java.util.ArrayList;
import java.util.Collection;
import com.xeiam.xchart.Chart;
import com.xeiam.xchart.LineChart;
import com.xeiam.xchart.SwingWrapper;
/**
......@@ -38,7 +37,7 @@ public class LineChart03 implements ExampleChart {
public Chart getChart() {
// Create Chart
Chart chart = new LineChart(800, 600);
Chart chart = new Chart(800, 600);
for (int i = 1; i <= 14; i++) {
......
......@@ -24,7 +24,6 @@ import java.util.Date;
import java.util.TimeZone;
import com.xeiam.xchart.Chart;
import com.xeiam.xchart.LineChart;
import com.xeiam.xchart.SwingWrapper;
import com.xeiam.xchart.style.Series;
import com.xeiam.xchart.style.StyleManager.LegendPosition;
......@@ -50,7 +49,7 @@ public class LineChart04 implements ExampleChart {
public Chart getChart() {
// Create Chart
Chart chart = new LineChart(800, 600);
Chart chart = new Chart(800, 600);
// generates linear data
Collection<Date> xData = new ArrayList<Date>();
......
......@@ -16,7 +16,6 @@
package com.xeiam.xchart.demo.charts.line;
import com.xeiam.xchart.Chart;
import com.xeiam.xchart.LineChart;
import com.xeiam.xchart.SwingWrapper;
/**
......@@ -35,7 +34,7 @@ public class LineChart06 implements ExampleChart {
public Chart getChart() {
// Create Chart
Chart chart = new LineChart(800, 600);
Chart chart = new Chart(800, 600);
// Customize Chart
chart.setChartTitle("LineChart06");
......
......@@ -19,7 +19,6 @@ import java.util.Arrays;
import java.util.Collection;
import com.xeiam.xchart.Chart;
import com.xeiam.xchart.LineChart;
import com.xeiam.xchart.SwingWrapper;
/**
......@@ -41,7 +40,7 @@ public class LineChart07 implements ExampleChart {
Collection<Number> yData = Arrays.asList(new Number[] { 0.0, 1.0, 2.0, 0.0, 1.0, 2.0, 0.0, 1.0, 2.0, 0.0 });
// Create Chart
Chart chart = new LineChart(800, 600);
Chart chart = new Chart(800, 600);
chart.setChartTitle("LineChart07");
chart.setXAxisTitle("X");
chart.setYAxisTitle("Y");
......
......@@ -19,7 +19,6 @@ import java.util.ArrayList;
import java.util.Collection;
import com.xeiam.xchart.Chart;
import com.xeiam.xchart.LineChart;
import com.xeiam.xchart.SwingWrapper;
import com.xeiam.xchart.style.Series;
import com.xeiam.xchart.style.SeriesColor;
......@@ -53,7 +52,7 @@ public class LineChart08 implements ExampleChart {
}
// Create Chart
Chart chart = new LineChart(800, 600);
Chart chart = new Chart(800, 600);
// Customize Chart
chart.getStyleManager().setChartTitleVisible(false);
......
......@@ -26,7 +26,6 @@ import java.util.Date;
import java.util.Locale;
import com.xeiam.xchart.Chart;
import com.xeiam.xchart.LineChart;
import com.xeiam.xchart.SwingWrapper;
import com.xeiam.xchart.style.ChartColor;
import com.xeiam.xchart.style.Series;
......@@ -50,7 +49,7 @@ public class LineChart09 implements ExampleChart {
public Chart getChart() {
// Create Chart
Chart chart = new LineChart(800, 600);
Chart chart = new Chart(800, 600);
// generates linear data
Collection<Date> xData = new ArrayList<Date>();
......
......@@ -16,7 +16,6 @@
package com.xeiam.xchart.demo.charts.line;
import com.xeiam.xchart.Chart;
import com.xeiam.xchart.LineChart;
import com.xeiam.xchart.SwingWrapper;
import com.xeiam.xchart.style.Series;
import com.xeiam.xchart.style.SeriesColor;
......@@ -39,7 +38,7 @@ public class LineChart10 implements ExampleChart {
public Chart getChart() {
// Create Chart
Chart chart = new LineChart(800, 600);
Chart chart = new Chart(800, 600);
// Customize Chart
chart.setChartTitle("LineChart10");
......
......@@ -20,9 +20,9 @@ import java.util.List;
import java.util.Random;
import com.xeiam.xchart.Chart;
import com.xeiam.xchart.ScatterChart;
import com.xeiam.xchart.SwingWrapper;
import com.xeiam.xchart.demo.charts.line.ExampleChart;
import com.xeiam.xchart.style.StyleManager.ChartType;
/**
* Gaussian Blob
......@@ -51,7 +51,8 @@ public class ScatterChart01 implements ExampleChart {
}
// Create Chart
Chart chart = new ScatterChart(800, 600);
Chart chart = new Chart(800, 600);
chart.getStyleManager().setChartType(ChartType.Scatter);
// Customize Chart
chart.getStyleManager().setChartTitleVisible(false);
......
......@@ -35,7 +35,7 @@ import com.xeiam.xchart.style.theme.Theme;
*
* @author timmolter
*/
public abstract class Chart {
public class Chart {
private int width;
private int height;
......@@ -74,6 +74,7 @@ public abstract class Chart {
setXAxisTitle(chartBuilder.xAxisTitle);
setYAxisTitle(chartBuilder.yAxisTitle);
setTheme(chartBuilder.theme);
getStyleManager().setChartType(chartBuilder.chartType);
}
/**
......
......@@ -21,6 +21,7 @@
*/
package com.xeiam.xchart;
import com.xeiam.xchart.style.StyleManager.ChartType;
import com.xeiam.xchart.style.theme.Theme;
import com.xeiam.xchart.style.theme.XChartTheme;
......@@ -29,11 +30,6 @@ import com.xeiam.xchart.style.theme.XChartTheme;
*/
public class ChartBuilder {
public enum ChartType {
Line, Scatter, Area
}
protected ChartType chartType = ChartType.Line;
protected int width = 800;
protected int height = 600;
......@@ -91,16 +87,7 @@ public class ChartBuilder {
*/
public Chart build() {
switch (chartType) {
case Line:
return new LineChart(this);
case Scatter:
return new ScatterChart(this);
case Area:
return new AreaChart(this);
default:
return new LineChart(this);
}
return new Chart(this);
}
......
......@@ -72,7 +72,7 @@ public final class QuickChart {
public static Chart getChart(String chartTitle, String xTitle, String yTitle, String[] seriesNames, double[] xData, double[][] yData) {
// Create Chart
Chart chart = new LineChart(WIDTH, HEIGHT);
Chart chart = new Chart(WIDTH, HEIGHT);
// Customize Chart
chart.setChartTitle(chartTitle);
......@@ -108,7 +108,7 @@ public final class QuickChart {
public static Chart getChart(String chartTitle, String xTitle, String yTitle, String seriesName, Collection<Number> xData, Collection<Number> yData) {
// Create Chart
Chart chart = new LineChart(WIDTH, HEIGHT);
Chart chart = new Chart(WIDTH, HEIGHT);
// Customize Chart
chart.setChartTitle(chartTitle);
......
......@@ -33,7 +33,7 @@ public class Axis implements ChartPart {
public enum AxisType {
NUMBER, DATE;
Number, Date, Logarithmic;
}
/** parent */
......@@ -66,7 +66,7 @@ public class Axis implements ChartPart {
private Rectangle paintZone;
/** An axis direction */
protected enum Direction {
public enum Direction {
/** the constant to represent X axis */
X,
......
......@@ -87,19 +87,19 @@ public class AxisPair implements ChartPart {
Iterator<?> itr = xData.iterator();
Object dataPoint = itr.next();
if (dataPoint instanceof Number) {
xAxis.setAxisType(AxisType.NUMBER);
xAxis.setAxisType(AxisType.Number);
} else if (dataPoint instanceof Date) {
xAxis.setAxisType(AxisType.DATE);
xAxis.setAxisType(AxisType.Date);
}
yAxis.setAxisType(AxisType.NUMBER);
yAxis.setAxisType(AxisType.Number);
series = new Series(seriesName, xData, xAxis.getAxisType(), yData, yAxis.getAxisType(), errorBars, seriesColorMarkerLineStyleCycler.getNextSeriesColorMarkerLineStyle());
} else { // generate xData
Collection<Number> generatedXData = new ArrayList<Number>();
for (int i = 1; i < yData.size() + 1; i++) {
generatedXData.add(i);
}
xAxis.setAxisType(AxisType.NUMBER);
yAxis.setAxisType(AxisType.NUMBER);
xAxis.setAxisType(AxisType.Number);
yAxis.setAxisType(AxisType.Number);
series = new Series(seriesName, generatedXData, xAxis.getAxisType(), yData, yAxis.getAxisType(), errorBars, seriesColorMarkerLineStyleCycler.getNextSeriesColorMarkerLineStyle());
}
......
......@@ -17,25 +17,15 @@ package com.xeiam.xchart.internal.chartpart;
import java.awt.Graphics2D;
import java.awt.Rectangle;
import java.math.BigDecimal;
import java.util.LinkedList;
import java.util.List;
import com.xeiam.xchart.Chart;
import com.xeiam.xchart.internal.chartpart.Axis.AxisType;
import com.xeiam.xchart.internal.chartpart.Axis.Direction;
/**
* An axis tick
*/
public class AxisTick implements ChartPart {
/** the default tick mark step hint for x axis */
private static final int DEFAULT_TICK_MARK_STEP_HINT_X = 74;
/** the default tick mark step hint for y axis */
private static final int DEFAULT_TICK_MARK_STEP_HINT_Y = 44;
/** parent */
private Axis axis;
......@@ -45,20 +35,14 @@ public class AxisTick implements ChartPart {
/** the axistickmarks */
private AxisTickMarks axisTickMarks;
/** the List of tick label position in pixels */
private List<Integer> tickLocations;
/** the List of tick label values */
private List<String> tickLabels;
private int workingSpace;
/** the bounds */
private Rectangle bounds;
/** the visibility state of axistick */
private boolean isVisible = true; // default to true
AxisTickComputer axisTickComputer;
/**
* Constructor
*
......@@ -84,6 +68,7 @@ public class AxisTick implements ChartPart {
bounds = new Rectangle();
int workingSpace = 0;
if (axis.getDirection() == Axis.Direction.Y) {
workingSpace = (int) axis.getPaintZone().getHeight(); // number of pixels the axis has to work with for drawing AxisTicks
// System.out.println("workingspace= " + workingSpace);
......@@ -92,16 +77,10 @@ public class AxisTick implements ChartPart {
// System.out.println("workingspace= " + workingSpace);
}
determineAxisTick();
// for (Integer position : tickLocations) {
// System.out.println(position);
// }
// for (String label : tickLabels) {
// System.out.println(label);
// }
axisTickComputer = new AxisTickComputer(axis.getDirection(), workingSpace, axis.getMin(), axis.getMax(), getChart().getValueFormatter(), axis.getAxisType());
if (isVisible) {
axisTickLabels.paint(g);
axisTickMarks.paint(g);
......@@ -121,136 +100,6 @@ public class AxisTick implements ChartPart {
}
/**
*
*/
private void determineAxisTick() {
tickLocations = new LinkedList<Integer>();
tickLabels = new LinkedList<String>();
// System.out.println("workingSpace= " + workingSpace);
int tickSpace = AxisPair.getTickSpace(workingSpace);
// System.out.println("tickSpace= " + tickSpace);
int margin = AxisPair.getTickStartOffset(workingSpace, tickSpace);
// a check if all axis data are the exact same values
if (axis.getMax() == axis.getMin()) {
tickLabels.add(format(axis.getMax()));
tickLocations.add((int) (margin + tickSpace / 2.0));
} else {
final BigDecimal min = new BigDecimal(axis.getMin().doubleValue());
BigDecimal firstPosition;
BigDecimal gridStep = getGridStep(tickSpace);
double xyz = min.remainder(gridStep).doubleValue();
if (xyz <= 0.0) {
firstPosition = min.subtract(min.remainder(gridStep));
} else {
firstPosition = min.subtract(min.remainder(gridStep)).add(gridStep);
}
for (BigDecimal b = firstPosition; b.compareTo(axis.getMax()) <= 0; b = b.add(gridStep)) {
// System.out.println("b= " + b);
tickLabels.add(format(b));
int tickLabelPosition = (int) (margin + ((b.subtract(axis.getMin())).doubleValue() / (axis.getMax().subtract(axis.getMin())).doubleValue() * tickSpace));
// System.out.println("tickLabelPosition= " + tickLabelPosition);
tickLocations.add(tickLabelPosition);
}
}
}
private BigDecimal getGridStep(int tickSpace) {
double length = Math.abs(axis.getMax().subtract(axis.getMin()).doubleValue());
// System.out.println(axis.getMax());
// System.out.println(axis.min);
// System.out.println(length);
int tickMarkSpaceHint = (axis.getDirection() == Direction.X ? DEFAULT_TICK_MARK_STEP_HINT_X : DEFAULT_TICK_MARK_STEP_HINT_Y);
// for very short plots, squeeze some more ticks in than normal
if (axis.getDirection() == Direction.Y && tickSpace < 160) {
tickMarkSpaceHint = 25;
}
double gridStepHint = length / tickSpace * tickMarkSpaceHint;
// gridStepHint --> mantissa * 10 ** exponent
// e.g. 724.1 --> 7.241 * 10 ** 2
double mantissa = gridStepHint;
int exponent = 0;
if (mantissa == 0) {
exponent = 1;
} else if (mantissa < 1) {
while (mantissa < 1) {
mantissa *= 10.0;
exponent--;
}
} else {
while (mantissa >= 10) {
mantissa /= 10.0;
exponent++;
}
}
// calculate the grid step with hint.
BigDecimal gridStep;
if (mantissa > 7.5) {
// gridStep = 10.0 * 10 ** exponent
gridStep = BigDecimal.TEN.multiply(pow(10, exponent));
} else if (mantissa > 3.5) {
// gridStep = 5.0 * 10 ** exponent
gridStep = new BigDecimal(new Double(5).toString()).multiply(pow(10, exponent));
} else if (mantissa > 1.5) {
// gridStep = 2.0 * 10 ** exponent
gridStep = new BigDecimal(new Double(2).toString()).multiply(pow(10, exponent));
} else {
// gridStep = 1.0 * 10 ** exponent
gridStep = pow(10, exponent);
}
return gridStep;
}
/**
* Calculates the value of the first argument raised to the power of the second argument.
*
* @param base the base
* @param exponent the exponent
* @return the value <tt>a<sup>b</sup></tt> in <tt>BigDecimal</tt>
*/
private BigDecimal pow(double base, int exponent) {
BigDecimal value;
if (exponent > 0) {
value = new BigDecimal(new Double(base).toString()).pow(exponent);
} else {
value = BigDecimal.ONE.divide(new BigDecimal(new Double(base).toString()).pow(-exponent));
}
return value;
}
/**
* Format the number
*
* @param value The number to be formatted
* @return The formatted number in String form
*/
private String format(BigDecimal value) {
if (axis.getAxisType() == AxisType.NUMBER) {
return getChart().getValueFormatter().formatNumber(value);
} else {
return getChart().getValueFormatter().formatDateValue(value, axis.getMin(), axis.getMax());
}
}
@Override
public Chart getChart() {
......@@ -259,23 +108,23 @@ public class AxisTick implements ChartPart {
// Getters /////////////////////////////////////////////////
public List<Integer> getTickLocations() {
public Axis getAxis() {
return tickLocations;
return axis;
}
public List<String> getTickLabels() {
public AxisTickLabels getAxisTickLabels() {
return tickLabels;
return axisTickLabels;
}
public Axis getAxis() {
public List<Integer> getTickLocations() {
return axis;
return axisTickComputer.getTickLocations();
}
public AxisTickLabels getAxisTickLabels() {
public List<String> getTickLabels() {
return axisTickLabels;
return axisTickComputer.getTickLabels();
}
}
/**
* Copyright (C) 2013 Xeiam LLC http://xeiam.com
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
* of the Software, and to permit persons to whom the Software is furnished to do
* so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package com.xeiam.xchart.internal.chartpart;
import java.math.BigDecimal;
import java.util.LinkedList;
import java.util.List;
import com.xeiam.xchart.internal.chartpart.Axis.AxisType;
import com.xeiam.xchart.internal.chartpart.Axis.Direction;
import com.xeiam.xchart.internal.chartpart.gridstep.DecimalGridStep;
import com.xeiam.xchart.style.ValueFormatter;
/**
* This class encapsulates the logic to generate the axis tick mark and axis tick label data for rendering the axis ticks
*
* @author timmolter
*/
public class AxisTickComputer {
/** the List of tick label position in pixels */
private List<Integer> tickLocations = new LinkedList<Integer>();;
/** the List of tick label values */
private List<String> tickLabels = new LinkedList<String>();
private final Direction axisDirection;
private final int workingSpace;
private final BigDecimal minValue;
private final BigDecimal maxValue;
private final ValueFormatter valueFormatter;
private final AxisType axisType;
/**
* Constructor
*
* @param axisDirection
* @param workingSpace
* @param minValue
* @param maxValue
* @param valueFormatter
* @param axisType
*/
public AxisTickComputer(Direction axisDirection, int workingSpace, BigDecimal minValue, BigDecimal maxValue, ValueFormatter valueFormatter, AxisType axisType) {
this.axisDirection = axisDirection;
this.workingSpace = workingSpace;
this.minValue = minValue;
this.maxValue = maxValue;
this.valueFormatter = valueFormatter;
this.axisType = axisType;
computeAxisTick();
}
private void computeAxisTick() {
System.out.println("workingSpace= " + workingSpace);
// a check if all axis data are the exact same values
if (maxValue == minValue) {
tickLabels.add(format(maxValue));
tickLocations.add((int) (workingSpace / 2.0));
return;
}
// tick space - a percentage of the working space available for ticks, i.e. 95%
int tickSpace = AxisPair.getTickSpace(workingSpace); // in plot space
System.out.println("tickSpace= " + tickSpace);
// where the tick should begin in the working space in pixels
int margin = AxisPair.getTickStartOffset(workingSpace, tickSpace); // in plot space
// the span of the data
double span = Math.abs(maxValue.subtract(minValue).doubleValue()); // in data space
BigDecimal gridStep = null;
BigDecimal firstPosition = null;
if (axisType == AxisType.Number) {
DecimalGridStep decimalGridStepHelper = new DecimalGridStep();
gridStep = decimalGridStepHelper.getGridStepForDecimal(axisDirection, span, tickSpace);
firstPosition = decimalGridStepHelper.getFirstPosition(minValue, gridStep);
} else if (axisType == AxisType.Date) {
} else if (axisType == AxisType.Logarithmic) {
}
// generate all tickLabels and tickLocations from the first to last position
for (BigDecimal tickPosition = firstPosition; tickPosition.compareTo(maxValue) <= 0; tickPosition = tickPosition.add(gridStep)) {
tickLabels.add(format(tickPosition));
// here we convert tickPosition finally to plot space, i.e. pixels
int tickLabelPosition = (int) (margin + ((tickPosition.subtract(minValue)).doubleValue() / (maxValue.subtract(minValue)).doubleValue() * tickSpace));
tickLocations.add(tickLabelPosition);
}
}
/**
* Format the number
*
* @param value The number to be formatted
* @return The formatted number in String form
*/
private String format(BigDecimal value) {
if (axisType == AxisType.Number) {
return valueFormatter.formatNumber(value);
} else {
return valueFormatter.formatDateValue(value, minValue, maxValue);
}
}
public List<Integer> getTickLocations() {
return tickLocations;
}
public List<String> getTickLabels() {
return tickLabels;
}
}
......@@ -87,6 +87,7 @@ public class AxisTickMarks implements ChartPart {
} else { // X-Axis
int xOffset = (int) (axisTick.getAxis().getPaintZone().getX());
// int yOffset = (int) (axisTick.getAxisTickLabels().getBounds().getY() - getChart().getStyleManager().getAxisTickPadding());
int yOffset = (int) (axisTick.getAxisTickLabels().getBounds().getY() - getChart().getStyleManager().getAxisTickPadding());
// tick marks
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment