Chart Calculations
Calculate Actual Values of Chart Elements
Aspose.Slides for Node.js via Java provides a simple API for getting these properties. Properties of Axis class provide information about actual position of axis chart element (Axis.getActualMaxValue, Axis.getActualMinValue, Axis.getActualMajorUnit, Axis.getActualMinorUnit, Axis.getActualMajorUnitScale, Axis.getActualMinorUnitScale). It is necessary to call method Chart.validateChartLayout() previously to fill properties with actual values.
var pres = new aspose.slides.Presentation();
try {
var chart = pres.getSlides().get_Item(0).getShapes().addChart(aspose.slides.ChartType.Area, 100, 100, 500, 350);
chart.validateChartLayout();
var maxValue = chart.getAxes().getVerticalAxis().getActualMaxValue();
var minValue = chart.getAxes().getVerticalAxis().getActualMinValue();
var majorUnit = chart.getAxes().getHorizontalAxis().getActualMajorUnit();
var minorUnit = chart.getAxes().getHorizontalAxis().getActualMinorUnit();
} finally {
if (pres != null) {
pres.dispose();
}
}
Calculate Actual Position of Parent Chart Elements
Aspose.Slides for Node.js via Java provides a simple API for getting these properties. Properties of ActualLayout class provide information about actual position of parent chart element (ActualLayout.getActualX, ActualLayout.getActualY, ActualLayout.getActualWidth, ActualLayout.getActualHeight). It is necessary to call method Chart.validateChartLayout() previously to fill properties with actual values.
var pres = new aspose.slides.Presentation();
try {
var chart = pres.getSlides().get_Item(0).getShapes().addChart(aspose.slides.ChartType.ClusteredColumn, 100, 100, 500, 350);
chart.validateChartLayout();
var x = chart.getPlotArea().getActualX();
var y = chart.getPlotArea().getActualY();
var w = chart.getPlotArea().getActualWidth();
var h = chart.getPlotArea().getActualHeight();
} finally {
if (pres != null) {
pres.dispose();
}
}
Hide Information from Chart
This topic helps you to understand how to hide information from chart. Using Aspose.Slides for Node.js via Java you can hide Title, Vertical Axis, Horizontal Axis and Grid Lines from chart. Below code example shows how to use these properties.
var pres = new aspose.slides.Presentation();
try {
var slide = pres.getSlides().get_Item(0);
var chart = slide.getShapes().addChart(aspose.slides.ChartType.LineWithMarkers, 140, 118, 320, 370);
// Hiding chart Title
chart.setTitle(false);
// /Hiding Values axis
chart.getAxes().getVerticalAxis().setVisible(false);
// Category Axis visibility
chart.getAxes().getHorizontalAxis().setVisible(false);
// Hiding Legend
chart.setLegend(false);
// Hiding MajorGridLines
chart.getAxes().getHorizontalAxis().getMajorGridLinesFormat().getLine().getFillFormat().setFillType(java.newByte(aspose.slides.FillType.NoFill));
for (var i = 0; i < chart.getChartData().getSeries().size(); i++) {
chart.getChartData().getSeries().removeAt(i);
}
var series = chart.getChartData().getSeries().get_Item(0);
series.getMarker().setSymbol(aspose.slides.MarkerStyleType.Circle);
series.getLabels().getDefaultDataLabelFormat().setShowValue(true);
series.getLabels().getDefaultDataLabelFormat().setPosition(aspose.slides.LegendDataLabelPosition.Top);
series.getMarker().setSize(15);
// Setting series line color
series.getFormat().getLine().getFillFormat().setFillType(java.newByte(aspose.slides.FillType.Solid));
series.getFormat().getLine().getFillFormat().getSolidFillColor().setColor(java.getStaticFieldValue("java.awt.Color", "MAGENTA"));
series.getFormat().getLine().setDashStyle(aspose.slides.LineDashStyle.Solid);
pres.save("HideInformationFromChart.pptx", aspose.slides.SaveFormat.Pptx);
} finally {
if (pres != null) {
pres.dispose();
}
}
FAQ
Do external Excel workbooks work as a data source, and how does that affect recalculation?
Yes. A chart can reference an external workbook: when you connect or refresh the external source, formulas and values are taken from that workbook, and the chart reflects the updates during open/edit operations. The API lets you specify the external workbook path and manage the linked data.
Can I compute and display trendlines without implementing regression myself?
Yes. Trendlines (linear, exponential, and others) are added and updated by Aspose.Slides; their parameters are recalculated from the series data automatically, so you don’t need to implement your own calculations.
If a presentation has multiple charts with external links, can I control which workbook each chart uses for computed values?
Yes. Each chart can point to its own external workbook, or you can create/replace an external workbook per chart independently of the others.