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.