Line charts are the most basic charts that are created by connecting the data points with straight lines. These charts are used to visualize a trend in data by comparing values against periodic intervals such as time, temperature etc. Some examples that can be well depicted using line charts are closing prices of a stock in a given time frame and monthly average sale of a product.
DsExcel supports the following types of line charts.
Chart Type | Chart Snapshot | Use Case |
---|---|---|
Line | Line chart is used to depict the data values plotted over time to display the trends. It shows continuous data over time on an evenly scaled Axis. | |
Line3D | Line3D chart is used to display the chart demonstration in 3D, which is a modification of 2D Line chart. | |
LineMarkers | LineMarkers chart is used to display data values shown with markers. It is ideal to use this chart when there are many categories or approximate values. | |
LineMarkersStacked | LineMarkersStacked is used to display data values with markers, typically showing the trend of contribution of each value over time or evenly spaced categories. | |
LineMarkersStacked100 | LineMarkersStacked100 chart is used to display individual data values with markers, typically showing the trend of the percentage each value that has been contributed over time or evenly spaced categories. It is ideal to use this chart when there are many categories or approximate values. | |
LineStacked | LineStacked chart is used to display stacked line to depict the trend of contribution of each data value or ordered category over different time intervals. | |
LineStacked100 | LineStacked100 chart is used to display displays trends in terms of the percentage that each data value or ordered category has contributed (to the whole) over different time intervals. |
Refer to the following example code to add LineStacked100 chart:
Java |
Copy Code |
---|---|
private static void LineCharts() { // Initialize workbook Workbook workbook = new Workbook(); // Fetch default worksheet IWorksheet worksheet = workbook.getWorksheets().get(0); // Prepare data for chart worksheet.getRange("A1:D4") .setValue(new Object[][] { { null, "Q1", "Q2", "Q3" }, { "Mobile Phones", 1330, 2345, 3493 }, { "Laptops", 2032, 3632, 2197 }, { "Tablets", 6233, 3270, 2030 } }); worksheet.getRange("A:D").getColumns().autoFit(); // Add Line Chart IShape areaChartShape = worksheet.getShapes().addChart(ChartType.LineMarkers, 250, 20, 360, 230); // Adding series to SeriesCollection areaChartShape.getChart().getSeriesCollection().add(worksheet.getRange("A1:D4"), RowCol.Columns, true, true); // Configure Chart Title areaChartShape.getChart().getChartTitle().getTextFrame().getTextRange().getParagraphs() .add("Annual Sales Record"); // Saving workbook to Xlsx workbook.save("21-LineChart.xlsx", SaveFileFormat.Xlsx); |