Hello, I'm trying to display a chart by salesperson, grouped by month, showing the total sales amount. I've attached a photo. I've tried many things without success. Thank you for your time.
I work with WinForms and VB.NET
3 Answers, 1 is accepted
Hello Jhon,
Thank you for contacting us.
I am not fully familiar with how your data is structured. However, what comes to my mind is to have different series for each salesperson. Then you can set the category, which is the same for each person, and the total sales amount. In the following example, I will have two sales persons, which are represented by 2 BarSeries:
public Form1()
{
InitializeComponent();
this.radChartView1.ShowLegend = true;
this.radChartView1.LegendTitle = "Legend";
BarSeries barSeries = new BarSeries("Performance", "RepresentativeName");
barSeries.Name = "Enero";
barSeries.LegendTitle = "Enero";
barSeries.DataPoints.Add(new CategoricalDataPoint(177, "ALDO CAJUSOL MONJA"));
barSeries.DataPoints.Add(new CategoricalDataPoint(128, "ANA PADILLA"));
barSeries.DataPoints.Add(new CategoricalDataPoint(143, "FYG"));
barSeries.DataPoints.Add(new CategoricalDataPoint(111, "KAG"));
barSeries.DataPoints.Add(new CategoricalDataPoint(118, "YULISSA AYALA"));
this.radChartView1.Series.Add(barSeries);
BarSeries barSeries2 = new BarSeries("Performance", "RepresentativeName");
barSeries2.Name = "Febrero";
barSeries2.LegendTitle = "Febrero";
barSeries2.DataPoints.Add(new CategoricalDataPoint(153, "ALDO CAJUSOL MONJA"));
barSeries2.DataPoints.Add(new CategoricalDataPoint(141, "ANA PADILLA"));
barSeries2.DataPoints.Add(new CategoricalDataPoint(130, "FYG"));
barSeries2.DataPoints.Add(new CategoricalDataPoint(88, "KAG"));
barSeries2.DataPoints.Add(new CategoricalDataPoint(109, "YULISSA AYALA"));
this.radChartView1.Series.Add(barSeries2);
}Here is the result:
You can extend the code and add more series and customize the RadChartView settings per your requirements.
Regards,
Dinko | Tech Support Engineer
Progress Telerik
Start the 2025 Survey
Good morning, I forgot to include the data structure. In this case, I'm using a DataTable retrieved from a database containing a single list of data (screenshot attached). I wanted to display a chart similar to the one attached. Thank you for your time.
Hello, I tried adapting your code using a foreach loop and got the following result; however, there must be a cleaner way to obtain the desired graph. I look forward to your feedback.
Dim dt_mes As New DataTable
Dim dt As New DataTable
dt_mes.Columns.Add("Mes")
rcvEstadistica.Series.Clear()
Me.rcvEstadistica.Area.View.Palette = KnownPalette.Metro
Me.rcvEstadistica.ShowLegend = True
Me.rcvEstadistica.ShowGrid = True
Me.rcvEstadistica.ShowSmartLabels = True
Me.rcvEstadistica.LegendTitle = "Total Mes : "
dt = Objeto_Reportes.Listar_ReporteVentaxProducto_Estadictico(empresa, fecha_I, fecha_F, agrupacion)
Dim MonthGroups = dt.AsEnumerable().GroupBy(Function(row) row.Field(Of String)("Mes"))
For Each NombreMes In MonthGroups
dt_mes.Rows.Add(UCase(NombreMes.Key))
Next
For Each mes As DataRow In dt_mes.Rows
Dim barSeria As New BarSeries
barSeria.Name = mes.Item("Mes").ToString
barSeria.LegendTitle = mes.Item("Mes").ToString
'barSeria.ShowLabels = True
For Each row As DataRow In dt.Rows
If row.Item("Mes").ToString = mes.Item("Mes").ToString Then
Dim val1 As Double = row("Importe_Mn")
Dim category As String = row("Vendedor")
Dim point1 As CategoricalDataPoint = New CategoricalDataPoint(val1, category)
barSeria.DataPoints.Add(point1)
End If
Next
rcvEstadistica.Series.Add(barSeria)
Next
You could also try to bind the RadChartView to a DataTable or BindingList. You can create them from your data. However, again, you will need to add different series. The legend on the right represents the series in the chart.
You can use the approach in this post or try to bind the RadChartView to a created DataTable or BindingList from your Data. You can check the Populating with Data section of the RadChartView control for more information.
