Page 1 of 1

How can I use ColorMember with BubbleSeries.

Posted: Wed Feb 04, 2004 8:05 pm
by 8122923
Hi,
I create a BubbleSeries fill with a DataSource. One of my columns specifies the color of the bubble should be. here a sample of my simple code :

styleBubble = new Steema.TeeChart.Styles.Bubble(chart);

styleBubble.DataSource = tablePoints;

styleBubble.YValues.DataMember = tablePoints.Columns["PourcentGrade1"].ToString();

styleBubble.XValues.DataMember = tablePoints.Columns["dureeSechage"].ToString();

styleBubble.RadiusValues.DataMember = tablePoints.Columns["Radius"].ToString();

// BEGIN THIS DON'T COMPILE
styleBubble.ColorMember = tablePoints.Columns["Couleur"].ToString();
// END THIS NOT COMPILE

chart.Series.Add(styleBubble);

How can I display a single bubbleSeries with different color specifie from my DataSource ? Is there any source exemple about this method ?

thanks a lot,
Philippe Lamontagne

Posted: Wed Feb 04, 2004 8:41 pm
by Marjan
Hi, Philippe.

What kind of an error do you receive ? You used the correct code which is also used in TeeChart .NET demo. Perhaps there is something wrong with the data you're storing in color column?

For an example of this feature check the "All Features -> Datasets -> Data Table XY series" example. Here is the relevant code from that example:

Code: Select all

		private void CreateTable()
		{
			Random r=new Random(255);
			
			// Create DataTable
			sourceTable = new DataTable("sourceTable");
			colXData = new DataColumn("XData",Type.GetType("System.Double"));
			colYData = new DataColumn("YData",Type.GetType("System.Double"));
			colDesc = new DataColumn("Desc",Type.GetType("System.String"));
			colColor = new DataColumn("Color",Type.GetType("System.Object"));

			sourceTable.Columns.Add(colXData);
			sourceTable.Columns.Add(colYData);
			sourceTable.Columns.Add(colDesc);
			sourceTable.Columns.Add(colColor);

			// Add table items.
			DataRow NewRow;
			double lastVal=0;
			for(int i = 0; i <10; i++)
			{
				Color cc=Color.FromArgb(r.Next(255),r.Next(255),r.Next(255));
				NewRow = sourceTable.NewRow();
				NewRow["Desc"] = "Label"+i.ToString();
				NewRow["XData"] = lastVal;
				NewRow["YData"] = r.Next(10);
				NewRow["Color"] = cc;
				sourceTable.Rows.Add(NewRow);
				lastVal=lastVal+5+r.Next(5);
			}

		}

		private void LoadData()
		{
			tChart1[0].Clear();

			//include Labels
			if (checkBox1.Checked)
			  tChart1[0].LabelMember=colDesc.ToString();
			else
				tChart1[0].LabelMember="";

			//include XValues
			if (checkBox2.Checked)
				tChart1[0].XValues.DataMember=colXData.ToString();
			else
				tChart1[0].XValues.DataMember="";

			tChart1[0].ColorMember=colColor.ToString();
			tChart1[0].YValues.DataMember=colYData.ToString();
			tChart1[0].DataSource=sourceTable;
		}

Thanks.

Posted: Thu Feb 05, 2004 6:48 pm
by 8122923
Thanks Marjan.
I was using a Int32 colums. I'm sure a DataType Color will help me :wink: