Hello,
I have a data-bound point chart that I'd like to change the point size of some points on. Ideally I'd like to have the point size read from a data column like the bubble chart, but I can't figure out how to do that. I have some code that goes through the Chart Series and updates the point size, but the points shift off their center point.
(I found a similar problem documented here) http://www.telerik.com/community/forums/aspnet-ajax/chart/how-to-set-a-size-changed-point-to-center-of-the-axes.aspx
My chart is plotting percentages for a variable number of people. I want to use the bubble size to show relative sample sizes in the percentages.
I've tried the Bubble chart, but it is difficult to get rid of ovals, especially when the chart resizes. There are a variable number of items in my chart, so it is not a grid. The bubble chart also has a problem when there is only one item in the chart. I've decided that a bubble chart cannot do what I want and a point chart is closer.
Is there a way to put the point back on its center coordinate? Or a way to use the bubble chart and get bubbles to be a pixel size (like the point chart) rather than use the coordinate system for plotting?
I'm using version 2011.3.11.1219 with the .NET 2.0 framework (Visual Studio 2010). My development machine is a Windows 7 - 64bit computer.
I've attached sample code that reproduces the problem. My real code loads data from a database and contains variable numbers of people.
Form1.cs
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Telerik.Charting;
namespace RadControlsWinFormsApp3
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
DataTable dtPage = new DataTable();
dtPage.TableName = "ChartData";
dtPage.Columns.Add("Name", typeof(String));
dtPage.Columns.Add("Completion", typeof(Double));
dtPage.Columns.Add("PointRadius", typeof(Double));
DataRow row = dtPage.NewRow();
row[0] = "Person1";
row[1] = .80d;
row[2] = 20d;
dtPage.Rows.Add(row);
row = dtPage.NewRow();
row[0] = "Person2";
row[1] = .65d;
row[2] = 40d;
dtPage.Rows.Add(row);
radChart1.DataSource = dtPage;
radChart1.DataBind();
//Force update of point sizes. We can't seem to do it from the bound data.
foreach (ChartSeries series in radChart1.Series)
{
if (series.Type == Telerik.Charting.ChartSeriesType.Point)
{
series.Appearance.PointDimentions.AutoSize = false;
foreach (ChartSeriesItem seriesItem in series.Items)
{
DataRow drow = dtPage.Rows[seriesItem.Index];
double radius = (double)drow["PointRadius"];
seriesItem.Appearance.PointDimentions.AutoSize = false;
seriesItem.Appearance.PointDimentions.Height = Telerik.Charting.Styles.Unit.Pixel((float)(radius * 2));
seriesItem.Appearance.PointDimentions.Width = Telerik.Charting.Styles.Unit.Pixel((float)(radius * 2));
//(seriesItem.PointAppearance.Position).Auto = false;
//(seriesItem.PointAppearance.Position).AlignedPosition = AlignedPositions.Center;
}
}
}
}
}
}
Form1.Designer.cs
namespace RadControlsWinFormsApp3
{
partial class Form1
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
Telerik.Charting.ChartAxisItem chartAxisItem1 = new Telerik.Charting.ChartAxisItem();
Telerik.Charting.ChartAxisItem chartAxisItem2 = new Telerik.Charting.ChartAxisItem();
Telerik.Charting.ChartAxisItem chartAxisItem3 = new Telerik.Charting.ChartAxisItem();
Telerik.Charting.ChartAxisItem chartAxisItem4 = new Telerik.Charting.ChartAxisItem();
Telerik.Charting.ChartAxisItem chartAxisItem5 = new Telerik.Charting.ChartAxisItem();
Telerik.Charting.ChartAxisItem chartAxisItem6 = new Telerik.Charting.ChartAxisItem();
Telerik.Charting.ChartAxisItem chartAxisItem7 = new Telerik.Charting.ChartAxisItem();
Telerik.Charting.ChartSeries chartSeries1 = new Telerik.Charting.ChartSeries();
this.radChart1 = new Telerik.WinControls.UI.RadChart();
((System.ComponentModel.ISupportInitialize)(this.radChart1)).BeginInit();
this.SuspendLayout();
//
// radChart1
//
this.radChart1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.radChart1.Location = new System.Drawing.Point(13, 13);
this.radChart1.Name = "radChart1";
this.radChart1.PlotArea.XAxis.AutoScale = false;
this.radChart1.PlotArea.XAxis.AxisLabel.Appearance.RotationAngle = 270F;
this.radChart1.PlotArea.XAxis.DataLabelsColumn = "Name";
chartAxisItem1.Value = new decimal(new int[] {
1,
0,
0,
0});
chartAxisItem2.Value = new decimal(new int[] {
2,
0,
0,
0});
chartAxisItem3.Value = new decimal(new int[] {
3,
0,
0,
0});
chartAxisItem4.Value = new decimal(new int[] {
4,
0,
0,
0});
chartAxisItem5.Value = new decimal(new int[] {
5,
0,
0,
0});
chartAxisItem6.Value = new decimal(new int[] {
6,
0,
0,
0});
chartAxisItem7.Value = new decimal(new int[] {
7,
0,
0,
0});
this.radChart1.PlotArea.XAxis.Items.AddRange(new Telerik.Charting.ChartAxisItem[] {
chartAxisItem1,
chartAxisItem2,
chartAxisItem3,
chartAxisItem4,
chartAxisItem5,
chartAxisItem6,
chartAxisItem7});
this.radChart1.PlotArea.XAxis.MinValue = 1D;
this.radChart1.PlotArea.YAxis.Appearance.CustomFormat = "## %";
this.radChart1.PlotArea.YAxis.AxisLabel.Appearance.RotationAngle = 0F;
this.radChart1.PlotArea.YAxis.MaxValue = 80D;
this.radChart1.PlotArea.YAxis.Step = 10D;
this.radChart1.PlotArea.YAxis2.AxisLabel.Appearance.RotationAngle = 0F;
chartSeries1.DataYColumn = "Completion";
chartSeries1.DefaultLabelValue = "#Y{p1}";
chartSeries1.Name = "Series 1";
chartSeries1.Type = Telerik.Charting.ChartSeriesType.Point;
this.radChart1.Series.AddRange(new Telerik.Charting.ChartSeries[] {
chartSeries1});
this.radChart1.SeriesOrientation = Telerik.Charting.ChartSeriesOrientation.Horizontal;
this.radChart1.Size = new System.Drawing.Size(473, 317);
this.radChart1.TabIndex = 0;
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(505, 362);
this.Controls.Add(this.radChart1);
this.Name = "Form1";
this.Text = "Form1";
((System.ComponentModel.ISupportInitialize)(this.radChart1)).EndInit();
this.ResumeLayout(false);
}
#endregion
private Telerik.WinControls.UI.RadChart radChart1;
}
}
Thanks