Page 1 of 1

Regarding Series Color and Gradient Color

Posted: Tue Mar 23, 2010 4:48 am
by 15055359
Hi,

we are trying to apply series color and gradient color in tChart Activex but we are not able to do that...
we have used javascrpt as scrptiong language and c# as server coding.

here is my sample.

aspnetForm.TChart1.Aspect.View3D = false;
aspnetForm.TChart1.Walls.Visible = true;

aspnetForm.TChart1.Panel.Gradient.Visible = true;
aspnetForm.TChart1.Panel.Gradient.StartColor = 4294951115;
aspnetForm.TChart1.Panel.Gradient.MidColor = 4294951115;
aspnetForm.TChart1.Panel.Gradient.EndColor = 4294951115;


aspnetForm.TChart1.Legend.Color = 4294309365;

var Colorarr = new Array();
Colorarr[0] = 4294309365;
Colorarr[1] = 4294951115;
Colorarr[2] = 4294967040;
Colorarr[3] = 4294902015;
Colorarr[4] = 4293821166;
Colorarr[5] = 4278222848;
Colorarr[6] = 4294956800;
Colorarr[7] = 4293982463;
Colorarr[8] = 4278190219;

var k;

for (k = 0; k < aspnetForm.TChart1.SeriesCount; k++)
{

aspnetForm.TChart1.Series(k).Active = true;
aspnetForm.TChart1.Series(k).Color = 4278190219;
aspnetForm.TChart1.Series(k).asFastLine.DrawAllPoints = true;
aspnetForm.TChart1.Series(k).asFastLine.FastPen = true;
aspnetForm.TChart1.Series(k).asFastLine.LinePen.Color = 4278190219;
aspnetForm.TChart1.Series(k).asFastLine.LinePen.Width = 2;

aspnetForm.TChart1.Series(k).ColorEachPoint = true;
}

we have used this aspnetForm because our chart page is in container of masterpage. and aspnetForm is our Master page Form tag.

please let me know if i am wrong anywhere.

and please let me know if any other alternative to do the same.

Thanks in Advance.
BNF Tech INC.

Re: Regarding Series Color and Gradient Color

Posted: Thu Mar 25, 2010 9:42 am
by yeray
Hi BNF Tech INC,

I've tried the following code in a WinForms application and it seems to work as expected:

Code: Select all

public Form1()
        {
            InitializeComponent();
            InitializeChart();
        }

        private void InitializeChart()
        {
            axTeeCommander1.ChartLink = axTChart1.ChartLink;

            axTChart1.Panel.Gradient.Visible = true;
            axTChart1.Panel.Gradient.StartColor = Convert.ToUInt32(ColorTranslator.ToOle(Color.Black));
            axTChart1.Panel.Gradient.MidColor = Convert.ToUInt32(ColorTranslator.ToOle(Color.Gray));
            axTChart1.Panel.Gradient.EndColor = Convert.ToUInt32(ColorTranslator.ToOle(Color.SlateGray));

            axTChart1.Legend.Color = Convert.ToUInt32(ColorTranslator.ToOle(Color.Yellow));

            for (int i = 0; i < 7; i++)
            {
                axTChart1.AddSeries(TeeChart.ESeriesClass.scFastLine);
                axTChart1.Series(i).FillSampleValues(25);
            }

            axTChart1.Aspect.View3D = false;

            uint[] Colorarr = new uint[3];
            Colorarr[0] = Convert.ToUInt32(ColorTranslator.ToOle(Color.Green));
            Colorarr[1] = Convert.ToUInt32(ColorTranslator.ToOle(Color.Blue));
            Colorarr[2] = Convert.ToUInt32(ColorTranslator.ToOle(Color.Red));

            for (int k = 0; k < axTChart1.SeriesCount; k++)
            {
                axTChart1.Series(k).Active = true;
                axTChart1.Series(k).Color = Colorarr[k % Colorarr.Length];
                axTChart1.Series(k).asFastLine.DrawAllPoints = true;
                axTChart1.Series(k).asFastLine.FastPen = true;
                axTChart1.Series(k).asFastLine.LinePen.Width = 2;
            }
        }
In your code you are defining and setting a Colorarr but it is not used... I've made some changes to your code to make it run in the WinForms application but nothing very significant.
Could you please try if the code above works fine for you in a simple WinForms application?
If it doesn't work, could you please check if you are using the latest TeeChart version available?
If it works fine, could you please send us a simple example WebSite project we can run as-is to reproduce the problem here?