Hello, I’ve been looking for a way to add a label to the y axis on a chart. We have an aspose .net word generated report file, that has a chart and needs to mimic the front end version of it.
I’ve searched through the foruns but I wasn’t able to find anything.
Here’s the front end chart
image.png (15.6 KB)
image.png (17.1 KB)
And there’s our aspose chart.
@jonroosevelt
The ChartAxis class represents the axis options of the chart and the ChartDataLabel class represents data label on a chart point or trendline.
Could you please share some more detail about chart label that you want to add to chart along with input and expected output documents? We will then provide you more information about your query.
It’s a bit hard to because it’s a very huge codebase and it’s very modulated.
But the main function behind the chart is as follows.
Anyways I just want to place a simple label, it won’t be dynamic or anything.
public void DrawChart(DocumentBuilder mBuilder, List<Tuple<decimal, decimal, int, string>> Data, ImageFieldMergingArgs args)
{
mBuilder.MoveToField(args.Field, true);
Shape shape = mBuilder.InsertChart(ChartType.Column, 500, 200);
Chart chart = shape.Chart;
chart.Title.Text = "Gráfico Comparativo";
chart.Series.Clear();
chart.AxisX.Scaling.Maximum = new AxisBound(100);
chart.Series.Add(
"Média dos Respondentes",
Data.Select(t => t.Item4).ToArray(),
Data.Select(t => Decimal.ToDouble(t.Item1)).ToArray()
);
chart.Series.Add(
"Você",
Data.Select(t => t.Item4).ToArray(),
Data.Select(t => Decimal.ToDouble(t.Item2)).ToArray()
);
ChartSeries series0 = shape.Chart.Series[0];
ChartSeries series1 = shape.Chart.Series[1];
args.Field.Remove();
}
I basically call this DrawChart function using a IFieldMergingCallBack. On the document I added a mergefield of a Image type like <Image:Chart>
Whenever the builder find this Field, it calls the DrawChart and places the Chart where it was supposed to be an image. It works pretty well, though it’s sort of a work around.
@jonroosevelt
Please ZIP and attach your input Word document along with expected output document. You can create your expected Word document using Microsoft Word and attach it here for our reference. We will investigate how you want your final Word output be generated like. We will then provide you more information on this along with code.