LineChartView Class
Contains settings that apply to line series in a chart view.
Declaration
public class LineChartView extends GroupedChartView
Remarks
When you add a LineSeries object to a chart, the chart creates a LineChartView object for the series. Call the Chart.getViews() method to access chart views.
To stack line series, call the LineChartView.setGrouping(value) method. Call setShowHighLowLines(boolean value) and setShowUpDownBars(boolean value) methods to display high-low lines and up-down bars (for example, in a stock chart).
Refer to the following help topic for additional information: Create Standard Charts — Presentation API for Java.
Example: Display High-Low Lines and Up-Down Bars in a Line Chart
The following code snippet creates a line chart with opening and closing prices, displays high-low lines, and colors up and down bars:
import java.io.*;
import java.nio.file.*;
import java.util.List;
import com.devexpress.docs.office.*;
import com.devexpress.docs.presentation.*;
import com.devexpress.system.drawing.*;
public class Main {
public static void main(String[] args) throws Exception {
try (Presentation presentation = new Presentation()) {
// Add a blank slide.
presentation.getSlides().clear();
Slide slide = new Slide(SlideLayoutType.BLANK);
presentation.getSlides().add(slide);
// Insert a chart that fills the slide.
Chart chart = new Chart();
chart.setWidth(presentation.getSlideSize().getWidth());
chart.setHeight(presentation.getSlideSize().getHeight());
slide.getShapes().add(chart);
// Add series for opening and closing prices.
String[] names = { "Open", "Close" };
double[][] prices = { { 102, 106, 104, 110, 108 }, { 106, 103, 109, 108, 114 } };
for (int i = 0; i < names.length; i++) {
LineSeries series = new LineSeries();
series.setText(names[i]);
series.setArguments(new ChartStringData(List.of("Mon", "Tue", "Wed", "Thu", "Fri")));
series.setValues(new ChartNumericData(List.of(prices[i][0], prices[i][1], prices[i][2], prices[i][3], prices[i][4])));
chart.getSeries().add(series);
}
// Display high-low lines.
LineChartView view = (LineChartView) chart.getViews().get(0);
view.setShowHighLowLines(true);
// Display green up bars and red down bars.
view.setShowUpDownBars(true);
view.setUpDownBarGapWidth(100);
ChartElement upBars = new ChartElement();
upBars.setFill(new SolidFill(Color.getSeaGreen()));
view.setUpBarProperties(upBars);
ChartElement downBars = new ChartElement();
downBars.setFill(new SolidFill(Color.getIndianRed()));
view.setDownBarProperties(downBars);
// Save the presentation.
Files.createDirectories(Path.of("output"));
try (OutputStream output = Files.newOutputStream(Path.of("output", "Chart.pptx"))) {
presentation.save(output);
}
}
}
}
Inherited Members
Inheritance
LineChartView()
Initializes a new instance of the LineChartView class.
Declaration
public LineChartView()
Methods
getChartType() Method
Returns the chart type of the view.
Declaration
public ChartType getChartType()
Returns
| Type | Description |
|---|---|
| ChartType |
|
getDataLabels() Method
Returns data label settings for all series in the view.
Declaration
public ILineDataLabels getDataLabels()
Returns
| Type | Description |
|---|---|
| ILineDataLabels | Data label settings. |
Remarks
Call the LineSeries.getDataLabels() method to access data label settings for an individual series.
Refer to the following help topic for additional information: Customize Chart Data Labels — Presentation API for Java.
getDownBarProperties() Method
Returns fill and outline settings for down bars.
Declaration
public ChartElement getDownBarProperties()
Returns
| Type | Description |
|---|---|
| ChartElement | Down bar settings, or |
getHighLowLineProperties() Method
Returns settings for high-low lines.
Declaration
public ChartElement getHighLowLineProperties()
Returns
| Type | Description |
|---|---|
| ChartElement | High-low line settings, or |
getShowHighLowLines() Method
Returns whether the view displays high-low lines.
Declaration
public boolean getShowHighLowLines()
Returns
| Type | Description |
|---|---|
| boolean |
|
getShowUpDownBars() Method
Returns whether the view displays up-down bars.
Declaration
public boolean getShowUpDownBars()
Returns
| Type | Description |
|---|---|
| boolean |
|
getSmooth() Method
Returns whether the view connects data points with smooth lines.
Declaration
public boolean getSmooth()
Returns
| Type | Description |
|---|---|
| boolean |
|
getUpBarProperties() Method
Returns fill and outline settings for up bars.
Declaration
public ChartElement getUpBarProperties()
Returns
| Type | Description |
|---|---|
| ChartElement | Up bar settings, or |
getUpDownBarGapWidth() Method
Returns the distance between up-down bars.
Declaration
public int getUpDownBarGapWidth()
Returns
| Type | Description |
|---|---|
| int | The gap width as a percentage of the bar width (from |
setDownBarProperties(ChartElement value) Method
Sets fill and outline settings for down bars.
Declaration
public void setDownBarProperties(ChartElement value)
Parameters
| Name | Type | Description |
|---|---|---|
| value | ChartElement | Down bar settings. |
Remarks
Note
Down bar settings take effect when you call the setShowUpDownBars(true) method.
setHighLowLineProperties(ChartElement value) Method
Sets settings for high-low lines.
Declaration
public void setHighLowLineProperties(ChartElement value)
Parameters
| Name | Type | Description |
|---|---|---|
| value | ChartElement | High-low line settings. |
Remarks
To specify the line color and width, pass a ChartElement object with outline settings to the setHighLowLineProperties(value) method.
Note
High-low line settings take effect when you call the setShowHighLowLines(true) method.
setShowHighLowLines(boolean value) Method
Sets whether the view displays high-low lines.
Declaration
public void setShowHighLowLines(boolean value)
Parameters
| Name | Type | Description |
|---|---|---|
| value | boolean |
|
Remarks
High-low lines connect the highest and lowest values in each category across all series in the view.
If you do not call the setShowHighLowLines(value) method, the API uses false. Call the setHighLowLineProperties(ChartElement value) method to specify the line color and width.
setShowUpDownBars(boolean value) Method
Sets whether the view displays up-down bars.
Declaration
public void setShowUpDownBars(boolean value)
Parameters
| Name | Type | Description |
|---|---|---|
| value | boolean |
|
Remarks
Up-down bars connect values of the first and last series in each category. The view displays an up bar if the last series value is greater than the first series value, and a down bar otherwise.
If you do not call the setShowUpDownBars(value) method, the API uses false. Call setUpBarProperties(ChartElement value), setDownBarProperties(ChartElement value), and setUpDownBarGapWidth(int value) methods to customize up-down bars.
setSmooth(boolean value) Method
Sets whether the view connects data points with smooth lines.
Declaration
public void setSmooth(boolean value)
Parameters
| Name | Type | Description |
|---|---|---|
| value | boolean |
|
Remarks
If you do not call the setSmooth(value) method, the API uses false.
Call the LineSeries.setSmooth(value) method to specify this setting for an individual series.
setUpBarProperties(ChartElement value) Method
Sets fill and outline settings for up bars.
Declaration
public void setUpBarProperties(ChartElement value)
Parameters
| Name | Type | Description |
|---|---|---|
| value | ChartElement | Up bar settings. |
Remarks
Note
Up bar settings take effect when you call the setShowUpDownBars(true) method.
setUpDownBarGapWidth(int value) Method
Sets the distance between up-down bars.
Declaration
public void setUpDownBarGapWidth(int value)
Parameters
| Name | Type | Description |
|---|---|---|
| value | int | The gap width as a percentage of the bar width (from |
Exceptions
| Type | Description |
|---|---|
| ArgumentOutOfRangeException | Thrown if the |
Remarks
The value range is from 0 to 500. If you do not call the setUpDownBarGapWidth(value) method, the API uses 150.
Note
The gap width takes effect when you call the setShowUpDownBars(true) method.