Hello Charles,
Thank you for contacting Telerik Support.
In order to display a
RadChartView in
RadGridView's cell, you may use the following approach.
public
Form1()
{
InitializeComponent();
GridServer.AutoSizeRows =
true
;
for
(
int
i = 0; i < 5; i++)
{
GridViewImageColumn imageColumn =
new
GridViewImageColumn(
"Server "
+ i);
imageColumn.ImageLayout = ImageLayout.Zoom;
GridServer.Columns.Add(imageColumn);
}
}
protected
override
void
OnLoad(EventArgs e)
{
base
.OnLoad(e);
GridViewRowInfo newRow = GridServer.Rows.NewRow();
foreach
(GridViewColumn column
in
GridServer.Columns)
{
RadChartView chart =
new
RadChartView();
LineSeries lineSeria =
new
LineSeries();
chart.Series.Add(lineSeria);
lineSeria.HorizontalAxis.LabelFitMode = Telerik.Charting.AxisLabelFitMode.MultiLine;
lineSeria.ValueMember =
"Value"
;
lineSeria.CategoryMember =
"DateTime"
;
lineSeria.DataSource = GetChartData();
chart.LoadElementTree();
Bitmap bmp =
new
Bitmap(chart.Width, chart.Height, PixelFormat.Format32bppArgb);
chart.DrawToBitmap(bmp,
new
Rectangle(0, 0, chart.Width, chart.Height));
newRow.Cells[column.Name].Value = bmp;
}
GridServer.Rows.Add(newRow);
}
private
DataTable GetChartData()
{
Random r =
new
Random();
DataTable table =
new
DataTable();
table.Columns.Add(
"DateTime"
,
typeof
(DateTime));
table.Columns.Add(
"Value"
,
typeof
(
double
));
for
(
int
i = 1; i <= 5; i++)
{
table.Rows.Add(DateTime.Now, r.Next(100));
table.Rows.Add(DateTime.Now.AddSeconds(30), r.Next(100));
table.Rows.Add(DateTime.Now.AddSeconds(60), r.Next(100));
table.Rows.Add(DateTime.Now.AddSeconds(90), r.Next(100));
table.Rows.Add(DateTime.Now.AddSeconds(120), r.Next(100));
table.Rows.Add(DateTime.Now.AddSeconds(150), r.Next(100));
}
return
table;
}
I hope this information helps. Should you have further questions, I would be glad to help.
Regards,
Desislava
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINFORMS.
Learn what features your users use (or don't use) in your application.
Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>