Lines 37-43
Link Here
|
37 |
public static void main(String[]args) throws Exception { |
37 |
public static void main(String[]args) throws Exception { |
38 |
Workbook wb = new XSSFWorkbook(); |
38 |
Workbook wb = new XSSFWorkbook(); |
39 |
CreationHelper creationHelper = wb.getCreationHelper(); |
39 |
CreationHelper creationHelper = wb.getCreationHelper(); |
40 |
Sheet sheet = wb.createSheet("new sheet"); |
40 |
Sheet sheet = wb.createSheet("Sheet 1"); |
41 |
final int NUM_OF_ROWS = 3; |
41 |
final int NUM_OF_ROWS = 3; |
42 |
final int NUM_OF_COLUMNS = 10; |
42 |
final int NUM_OF_COLUMNS = 10; |
43 |
|
43 |
|
Lines 57-63
Link Here
|
57 |
|
57 |
|
58 |
Chart chart = drawing.createChart(anchor); |
58 |
Chart chart = drawing.createChart(anchor); |
59 |
ChartLegend legend = chart.getOrCreateLegend(); |
59 |
ChartLegend legend = chart.getOrCreateLegend(); |
60 |
legend.setPosition(LegendPosition.RIGHT); |
60 |
legend.setPosition(LegendPosition.TOP_RIGHT); |
61 |
|
61 |
|
62 |
ScatterChartData data = chart.getChartDataFactory().createScatterChartData(); |
62 |
ScatterChartData data = chart.getChartDataFactory().createScatterChartData(); |
63 |
|
63 |
|
Lines 65-76
Link Here
|
65 |
ValueAxis leftAxis = chart.getChartAxisFactory().createValueAxis(AxisPosition.LEFT); |
65 |
ValueAxis leftAxis = chart.getChartAxisFactory().createValueAxis(AxisPosition.LEFT); |
66 |
|
66 |
|
67 |
ScatterChartSerie firstSerie = data.addSerie(); |
67 |
ScatterChartSerie firstSerie = data.addSerie(); |
68 |
firstSerie.setXValues(sheet, new CellRangeAddress(0, 0, NUM_OF_COLUMNS + 1, NUM_OF_COLUMNS + 1)); |
68 |
firstSerie.setXValues(sheet, new CellRangeAddress(0, 0, 0, NUM_OF_COLUMNS - 1)); |
69 |
firstSerie.setYValues(sheet, new CellRangeAddress(1, 1, NUM_OF_COLUMNS + 1, NUM_OF_COLUMNS + 1)); |
69 |
firstSerie.setYValues(sheet, new CellRangeAddress(1, 1, 0, NUM_OF_COLUMNS - 1)); |
70 |
|
70 |
|
71 |
ScatterChartSerie secondSerie = data.addSerie(); |
71 |
ScatterChartSerie secondSerie = data.addSerie(); |
72 |
secondSerie.setXValues(sheet, new CellRangeAddress(0, 0, NUM_OF_COLUMNS + 1, NUM_OF_COLUMNS + 1)); |
72 |
secondSerie.setXValues(sheet, new CellRangeAddress(0, 0, 0, NUM_OF_COLUMNS - 1)); |
73 |
secondSerie.setYValues(sheet, new CellRangeAddress(2, 2, NUM_OF_COLUMNS + 1, NUM_OF_COLUMNS + 1)); |
73 |
secondSerie.setYValues(sheet, new CellRangeAddress(2, 2, 0, NUM_OF_COLUMNS - 1)); |
74 |
|
74 |
|
75 |
chart.plot(data, bottomAxis, leftAxis); |
75 |
chart.plot(data, bottomAxis, leftAxis); |
76 |
|
76 |
|