How to set NPOI excel chart title style (Overlay = false)? - styles

XSSFChart chart;
chart.SetTitle();
I know how to set the title, but can't find a way to set the title not to overlay the chart

chart.GetCTChartSpace().chart.title.overlay = new CT_Boolean() { val = 0 };

Related

How do you set the font size of a Chart Title with Python PPTX?

I add a chart with:
doughnutchart_data.add_series('YTD COMPLETION TO PLAN', (PerformancePercent, NotPerformedPercent))
This gives me a chart title with the text, but how do I change the font size?
This:
ThisDoughnutChart.title.font.size = Pt(12)
Gives me this error:
AttributeError: 'Chart' object has no attribute 'title'
It seems that creating a chart title text_frame over writes the title applied from the add_series attribute. So I tried adding a new title. This worked for me:
ThisDoughnutChart.chart_title.text_frame.text = 'YTD COMPLETION TO PLAN'
ThisDoughnutChart.chart_title.text_frame.paragraphs[0].font.size = Pt(12)
Version 0.6.11 another example
shape = slide.shapes
title_shape = shape.title
title_shape.text_frame.paragraphs[0].font.size=Pt(10)
You can set the global font size of the chart with the following:
from pptx.util import Inches, Pt
ThisDoughnutChart.font.size = Pt(10)

How to set month Column width in AnyGantt?

Is it possible to change the width of month column in AnyGantt from AnyChart ?
This how my table look like
anychart.onDocumentReady(function() {
// create data tree on our data
var treeData = anychart.data.tree(getData(), anychart.enums.TreeFillingMethod.AS_TABLE);
// create resource gantt chart
chart = anychart.ganttResource();
// set container id for the chart
chart.container("container");
// set data for the chart
chart.data(treeData);
// set start splitter position settings
chart.splitterPosition(200);
// get chart data grid link to set column settings
var dataGrid = chart.dataGrid();
// initiate chart drawing
chart.draw();
Are you looking for zoom control?
chart.xScale().minimum(Date.UTC(2000, 1, 2));
chart.xScale().maximum(Date.UTC(2000, 3, 6));
// Set zoom to range.
chart.zoomTo("week", 2, "firstDate");
https://api.anychart.com/7.14.3/anychart.charts.Gantt#zoomTo
https://playground.anychart.com/api/7.14.3/charts/anychart.charts.Gantt.zoomTo_set_asInterval-plain
Also, there are:
https://api.anychart.com/7.14.3/anychart.charts.Gantt#fitAll
https://api.anychart.com/7.14.3/anychart.charts.Gantt#zoomIn
https://api.anychart.com/7.14.3/anychart.charts.Gantt#zoomOut

How to create Apache POI stacked Barchart

I want to create "stacked bar chart" using apache poi library. Need some documentation.
row1 = worksheet.createRow(r);
row['data'].flatten.each_with_index do |data, index|
cell = row1.createCell(index);
cell.setCellValue(data);
end
drawing = worksheet.createDrawingPatriarch();
anchor = drawing.createAnchor(0, 0, 0, 0, 0, 5, 8, 20);
chart = drawing.createChart(anchor);
ctChart = chart.getCTChart();
ctPlotArea = ctChart.getPlotArea();
ctBarChart = ctPlotArea.addNewBarChart();
ctBoolean = ctBarChart.addNewVaryColors();
ctBoolean.setVal(true);
ctBarChart.addNewBarDir().setVal(STBarDir.BAR);
ctBarChart.addNewGrouping().setVal(STBarGrouping.STACKED);
ctBarSer = ctBarChart.addNewSer();
ctSerTx = ctBarSer.addNewTx();
ctStrRef = ctSerTx.addNewStrRef();
ctStrRef.setF("Sheet1!$A$#{r+1}");
ctBarSer.addNewIdx().setVal(r+1);
cttAxDataSource = ctBarSer.addNewCat();
ctStrRef = cttAxDataSource.addNewStrRef();
length = row['data'].flatten.length
ctStrRef.setF("Sheet1!$B$#{r+1}:$#{CellReference.convertNumToColString(length-1)}$#{r + 1}");
ctNumDataSource = ctBarSer.addNewVal();
ctNumRef = ctNumDataSource.addNewNumRef();
ctNumRef.setF("Sheet1!$B$#{r+1}:$#{CellReference.convertNumToColString(length-1)}$#{r+1}");
ctBarSer.addNewSpPr().addNewLn().addNewSolidFill().addNewSrgbClr().setVal([0,0,0]);
Using above code I am getting bar chart but need to convert to stacked bar chart.
enter image description here
While I can't tell you exactly what the magic incantation to make your chart work is, I can help you work through your issue.
If the type of chart you want to create is not supported by POI. You are going to have to create it manually. Seems you have a good start on that. You can find specification documents here http://www.ecma-international.org/publications/standards/Ecma-376.htm. POI uses the 1st edition of the spec.
While these documents are very good, you might need some help determining just how to structure the XML. The way I go about it is to create a simple document using Excel or Word, then rename the saved document as *.zip. Now you can inspect the xml package using Notepad++ or some other viewer.
Once you have something generated with POI, you can also view the resulting XML in a similar manner to se what the differences are if the results are not as expected.

Why does setting a color to a cell not work (Aspose Cells)?

I have this code to try to set the background color of a cell (among other things):
private static readonly Color CONTRACT_ITEM_COLOR = Color.FromArgb(255, 255, 204);
. . .
cell = pivotTableSheet.Cells[4, 0];
cell.PutValue(AnnualContractProductsLabel);
style = cell.GetStyle();
style.HorizontalAlignment = TextAlignmentType.Center;
style.VerticalAlignment = TextAlignmentType.Center;
style.Font.IsBold = true;
pivotTableSheet.Cells.SetRowHeight(4, 25);
style.BackgroundColor = CONTRACT_ITEM_COLOR;
pivotTableSheet.Cells[4, 0].SetStyle(style);
The setting of horizontal and vertical alignment works, as does bold and height - everything but color:
What is yet needed? I have even tried setting ForegroundColor as well as Background colors, to :
style.ForegroundColor = Color.Red;
style.BackgroundColor = Color.Blue;
...but neither does anything - the cell still looks exactly the same as the screenshot above.
Please change your code segment to (see the highlighted lines):
e.g
Sample code:
. . .
cell = pivotTableSheet.Cells[4, 0];
cell.PutValue(AnnualContractProductsLabel);
style = cell.GetStyle();
style.HorizontalAlignment = TextAlignmentType.Center;
style.VerticalAlignment = TextAlignmentType.Center;
style.Font.IsBold = true;
pivotTableSheet.Cells.SetRowHeight(4, 25);
**style.ForegroundColor = CONTRACT_ITEM_COLOR;
style.Pattern = BackgroundType.Solid;**
pivotTableSheet.Cells[4, 0].SetStyle(style);
..........
it should work fine.
I am working as Support developer/ Evangelist at Aspose.
Sometimes setting background works, sometimes it doesn't. Aspose is full of bugs -- ClosedXML is much more reliable but harder to use. Wish I would not have spent the money on a product that was developed by third party in third world county.
var cells = worksheet.Cells; //get cells collection from active worksheet <br>
var srcCells = workbook.Worksheets[1].Cells;<br>
for (int i = 0; i<rowCount; i++)<br>
{<br>
var srcStyle = srcCells[i, 0].GetStyle();<br>
var destStyle = cells[i, 0].GetStyle();<br>
destStyle.Pattern = BackgroundType.Solid;<br>
destStyle.ForegroundColor = Color.FromArgb(srcStyle.ForegroundArgbColor);<br>
cells[i, 0].SetStyle(destStyle);<br>
}<br>
Above Code does not work. srcStyle Foreground color argb is 170,215,255.
Debugging code destStyle ForegroundColor is set to 170,215,255 but when saved as xlsx all the cell backgrounds are white.
In ClosedXML code the following code works perfectly
worksheet.Row(i).Cell(0).Style.BackgroundColor = Color.FromArgb(argb)
Conclusion: Save $$$$$ and use ClosedXML
enter image description here
all is fine only ForegroundColor is not showing

Remove label from Steema Bar Chart

How remove the label of each bar in the chart
and need to set Title for the Chart.
How remove the label of each bar in the chart
tChart1[0].Marks.Visible = false;
and need to set Title for the Chart.
tChart1.Header.Visible = true;
tChart1.Header.Text = "Chart title";

Resources