Hi Team,
I have a table in which I am trying to add a bar showing the responses. The offset is calculated as follows in the below method. But the bars look misaligned. Is this an issue with aspose? Could you please help resolving?
Code as follows, Please check the line where rectabgle is created. Bar offset is set with the table.Y and table cell offset.
private static IList formatBarData(CellFormaterMessage message)
{
var tableCell = message.TableCell;
var dataCell = message.DataCell;
var dataRow = message.DataRow;
var width = (float)tableCell.Width - (2 * horizontalPadding);
Func<double, float> calculateWidth = val => (width / 180) * (float)val;
Func<double, float> calculateNewWidth = val => (width / 100) * (float)val;
float barWidth = 0;
tableCell.TextFrame.Paragraphs.Clear();
Paragraph p = new Paragraph();
p.Text = dataCell.Title;
p.ParagraphFormat.Alignment = TextAlignment.Left;
p.ParagraphFormat.DefaultPortionFormat.LatinFont = new FontData(message.DesignSettings.GetValueOrDefault("@UISetting-OnScreenReport-Tables-Row-Font-Type").Split(’,’)[0]);
tableCell.TextFrame.Paragraphs.Add§;
tableCell.TextAnchorType = TextAnchorType.Top;
// tableCell.TextAnchorType = TextAnchorType.Center;
bool is100Perc = false;
if (message.DataCell.BarLength.HasValue)
{
barWidth = message.DataCell.BarLength.Value;
}
else
{
barWidth = float.Parse(message.DataCell.Title.Substring(0, message.DataCell.Title.Length - 1));
}
float newBarWidth = calculateNewWidth(barWidth);
if (barWidth ==100)
{
is100Perc = true;
// p.Text = “\n " + p.Text;
}
var r = AddShapeUtils.AddRectangle((ISlide)message.TableCell.Slide, message.DesignSettings.GetValueOrDefault(”@UISetting-OnScreenReport-Charts-Series1-Color").GetColor(), message.DesignSettings, (float)tableCell.OffsetX + message.Table.X + horizontalPadding,
(float)tableCell.OffsetY + message.Table.Y + verticalPadding, is100Perc ? calculateWidth(barWidth) : newBarWidth, height);
r.Name = “Bar” + shapeID.ToString();
shapeID++;
if (dataRow.ItemType == QVDatasourceTransformer.Page.DataView.ItemTypeEnum.Category)
{
SetCategoryRowFontAndBackground(p, message, tableCell);
tableCell.TextFrame.OnEachPortion(
portion =>
{
portion.PortionFormat.FontBold = NullableBool.True;
});
}
else
{
SetRowFontAndBackground(p, message, tableCell);
tableCell.TextFrame.OnEachParagraph(
paragraph =>
{
paragraph.ParagraphFormat.MarginLeft = is100Perc ? calculateWidth(barWidth) : newBarWidth;
});
}
return new List {r};
}