Controlling the linestyle of FirstVisibleIndex-1

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
BenW
Advanced
Posts: 119
Joined: Wed Aug 10, 2005 4:00 am

Controlling the linestyle of FirstVisibleIndex-1

Post by BenW » Wed Nov 02, 2011 2:53 am

I submitted a post last Saturday (Oct 29, 2011), but have not received a reply, hence this new post.

I am using version 2 of the Steema Teechart.

I have added the capability to allow a line series to plot its pointers (one per x,y sample)in different colors. Additionally by using the technique below, I have been able to show the line that connects sample A to sample B in the color of the pointer used to draw sample A, and also in a pre-specified line style:

void lineSeries_GetPointerStyle(Steema.TeeChart.Styles.CustomPoint series, Steema.TeeChart.Styles.CustomPoint.GetPointerStyleEventArgs e)
{
lock (seriesUpdateLock)
{
// Get the Data Quality lists for this series...
Hashtable thisSeriesDQColorList = this.trendDQColorsForSeries[series] as Hashtable;
Hashtable thisSeriesDQLineStyleList = this.trendDQLineStyleForSeries[series] as Hashtable;

if (thisSeriesDQColorList != null &&
thisSeriesDQLineStyleList != null)
{
if (e.ValueIndex >= 0 &&
series != null &&
e.ValueIndex < thisSeriesDQColorList.Count &&
e.ValueIndex < thisSeriesDQLineStyleList.Count)
{
int nextIndex = e.ValueIndex + 1;
if (nextIndex < (series.LastVisibleIndex + 1))
{
if (thisSeriesDQColorList.ContainsKey(series.XValues.AsDateTime(nextIndex)) &&
thisSeriesDQLineStyleList.ContainsKey(series.XValues.AsDateTime(nextIndex)))
{
series.Pointer.Color = (Color)thisSeriesDQColorList[series.XValues.AsDateTime(nextIndex)];
series.Pointer.Pen.Color = series.Pointer.Color;
series.LinePen.Style = (System.Drawing.Drawing2D.DashStyle)thisSeriesDQLineStyleList[series.XValues.AsDateTime(nextIndex)];
}
}
else if (nextIndex == (series.LastVisibleIndex + 1))
{
if (thisSeriesDQColorList.ContainsKey(series.XValues.AsDateTime(series.FirstVisibleIndex)) &&
thisSeriesDQLineStyleList.ContainsKey(series.XValues.AsDateTime(series.FirstVisibleIndex)))
{
series.Pointer.Color = (Color)thisSeriesDQColorList[series.XValues.AsDateTime(series.FirstVisibleIndex)];
series.Pointer.Pen.Color = series.Pointer.Color;
series.LinePen.Style = (System.Drawing.Drawing2D.DashStyle)thisSeriesDQLineStyleList[series.XValues.AsDateTime(series.FirstVisibleIndex)];
}
}
}
}
}
}


Using this technique works well, except that the line-style of the sample from series.FirstVisibleIndex-1 to series.FirstVisibleIndex is drawn in the line-style of that used to draw the line from series.FirstVisibleIndex to series.FirstVisibleIndex+1.

I can find no technique to control this situation so that the offending line is drawn with the correct line style.

Basically my functionality is to have the line connecting sample A to sample B be drawn in the same color as that used to draw the pointer at sample A, and to have a line style that is pre-specified for sample A.

I cannot find a solution to this by making changes to the lineSeries_GetPointerStyle method. It seems as though it is impossible to control the line drawn from sample series.FirstVisibleIndex-1 to series.FirstvisibleIndex, or to have any access to this line from the lineSeries_GetPointerStyle event.

The best I came up with is to try and delete and then redraw the line in the Series_AfterDrawValues event as per:


Steema.TeeChart.Styles.Series s = sender as Steema.TeeChart.Styles.Series;
if (s != null)
{
s.Chart.Graphics3D.ClearClipRegions();

if (s.Chart != null &&
s.FirstVisibleIndex > 0 &&
ChartCustomDataQualityConfig.GetCustomDQConfigured() == true)
{
Hashtable thisSeriesDQColorList = this.trendDQColorsForSeries[s] as Hashtable;
Hashtable thisSeriesDQLineStyleList = this.trendDQLineStyleForSeries[s] as Hashtable;
if (thisSeriesDQColorList != null &&
thisSeriesDQLineStyleList != null &&
(System.Drawing.Drawing2D.DashStyle)thisSeriesDQLineStyleList[s.XValues.AsDateTime(s.FirstVisibleIndex)] != (System.Drawing.Drawing2D.DashStyle)thisSeriesDQLineStyleList[s.XValues.AsDateTime(s.FirstVisibleIndex - 1)])
{
g.Pen.Width = ((Steema.TeeChart.Styles.Line)s).LinePen.Width;
Rectangle chartRect = g.Chart.ChartRect;
g.ClipRectangle(chartRect);
g.Pen.Color = g.Chart.Panel.Color;
g.Pen.Style = (System.Drawing.Drawing2D.DashStyle)thisSeriesDQLineStyleList[s.XValues.AsDateTime(s.FirstVisibleIndex)];
DNALog.WriteLog(DNALog.LogLevel.Always, "g.Pen.Color prior to delete call: " + g.Pen.Color.ToString() + " g.Pen.Style = " + g.Pen.Style.ToString());
g.Brush.Color = g.Chart.Panel.Color;
System.Drawing.Pen erasePen = new System.Drawing.Pen(g.Chart.Panel.Color);
erasePen.Width = ((Steema.TeeChart.Styles.Line)s).LinePen.Width;
erasePen.DashStyle = (System.Drawing.Drawing2D.DashStyle)thisSeriesDQLineStyleList[s.XValues.AsDateTime(s.FirstVisibleIndex)];
PointF startPoint = new PointF(s.CalcXPos(s.FirstVisibleIndex - 1), s.CalcYPos(s.FirstVisibleIndex - 1));
//PointF endPoint = new PointF(s.CalcXPos(s.FirstVisibleIndex) - (((Steema.TeeChart.Styles.Line)s).Pointer.HorizSize + 1), s.CalcYPos(s.FirstVisibleIndex) - (((Steema.TeeChart.Styles.Line)s).Pointer.HorizSize + 1));
PointF endPoint = new PointF(s.CalcXPos(s.FirstVisibleIndex), s.CalcYPos(s.FirstVisibleIndex) );
g.DrawLine(erasePen, startPoint, endPoint);
//g.Line((s.CalcXPos(s.FirstVisibleIndex - 1)), s.CalcYPos(s.FirstVisibleIndex - 1), s.CalcXPos(s.FirstVisibleIndex), s.CalcYPos(s.FirstVisibleIndex));
g.Pen.Width = ((Steema.TeeChart.Styles.Line)s).LinePen.Width;
g.Pen.Color = (System.Drawing.Color)(thisSeriesDQColorList[s.XValues.AsDateTime(s.FirstVisibleIndex - 1)]);
g.Pen.Style = (System.Drawing.Drawing2D.DashStyle)thisSeriesDQLineStyleList[s.XValues.AsDateTime(s.FirstVisibleIndex - 1)];
DNALog.WriteLog(DNALog.LogLevel.Always, "g.Pen.Color after delete call: " + g.Pen.Color.ToString() + " g.Pen.Style = " + g.Pen.Style.ToString());
}
}

Doing something like the above, does not completely erase the existing line cleanly. There are always some remnants left on the screen, so the re-drawn line looks messy and line style cannot really be determined. Also, the point where the deleted line crosses the pointer, is left with a deleted portion.

1. Is there a way to delete and redraw the line from series.FirstVisibleIndex-1 to series.FirstVisibleIndex?
2. Is there something that can be done in the lineSeries_GetPointerStyle event handle to control the item in 1. Above.
3. Is my required functionality readily implementable in a more recent version of the Steema Teechart control?
4. Is there a way to hide the line that is drawn from series.FirstVisibleIndex-1 to series.FirstVislbeIndex (assuming it exists)
5.
Please, any help/recommendations would be appreciated!

Thanks,
Ben.

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Re: Controlling the linestyle of FirstVisibleIndex-1

Post by Sandra » Wed Nov 02, 2011 4:20 pm

Hello Ben,

I'm not sure understand what are you need do. So I would be very grateful,if you can send us a simple project, so we can work with it to try to find a good answer for your requests.

Thanks,
Best Regards,
Sandra Pazos / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

BenW
Advanced
Posts: 119
Joined: Wed Aug 10, 2005 4:00 am

Re: Controlling the linestyle of FirstVisibleIndex-1

Post by BenW » Thu Nov 03, 2011 8:38 am

Hi Sandra.

I have uploaded an app that will demonstrate my problem. The file is called ProblemDemo.zip.

If you build and run this app, you will that when the chart is first drawn, the first sample (to the left of the chart) is red and line following the sample is also red with a dashstyle of dash. The magic to have the line following the pointer to be the same color is achieved via combination of adding new samples with a color that was supposed to be applied to the previous sample, and the code in the lineSeries_GetPointerStyle method. The next sample is Green with the line following in Green and with a DashStyle of DashDot, etc, etc (if you look at the CreatChart() method you'll see how this look is created via the Add commands). This visual representation is correct when first called up.

Now, if you press the RMB and drag the mouse horizontally to the left to scroll the chart in that direction (slowly), you'll notice that when the red pointer disappears, the DashStyle of the line changes from dashed to DotDash (the line style of green line, which immediately follows the red line). Similarly, if you continue scrolling to the left, then as soon as the green marker disappears, the DashStyle of the remaining part of the green line changes from DotDash to the Dash style of the blue line (DashDotDot) - or sometimes the blue line will change to the line style of the green line, until you move the green line back to the right, a little.

So this is the problem I need to be able to solve. When panning left or right, the line style of the line being panned off visually, should be consistent and not change.

Hopefully there is an easy way to solve this problem.

Regards,
Ben.

BenW
Advanced
Posts: 119
Joined: Wed Aug 10, 2005 4:00 am

Re: Controlling the linestyle of FirstVisibleIndex-1

Post by BenW » Thu Nov 03, 2011 4:59 pm

Hi Sandra.

I wanted to download an evaluation copy of the most recent Steema Teechart .NET, so I completed the Evaluation and no-charge software download form. When I logged on I couldn't see anything that was relevant. Can you pelase advise as to how I can get the most recent evaluation version (is that V4 ?). Do you think the most recent evaluation version can be configured/coded to solve my problems, as described in this thread?

Thanks,
Ben.

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Re: Controlling the linestyle of FirstVisibleIndex-1

Post by Sandra » Fri Nov 04, 2011 1:34 pm

Hello BenBw,
I wanted to download an evaluation copy of the most recent Steema Teechart .NET, so I completed the Evaluation and no-charge software download form. When I logged on I couldn't see anything that was relevant. Can you pelase advise as to how I can get the most recent evaluation version (is that V4 ?).
Ok. You can download last version of TeeChart.Net in the client download page. If you have any problems, with download process please let me know.
Do you think the most recent evaluation version can be configured/coded to solve my problems, as described in this thread?
All of your features can be implemented in last version of TeeChart.Net. Moreover last version of TeeChart.Net ofers you an best performance and improvement of features of TeeChart.Net,because you can achieve your projects have optimal results. I recommend that take a look here where you can see the Features, screenshots, demos and specifications.

On the other hand, I have made two projects one in last version of TeeChart.Net and the other in last version 2 of TeeChart.Net. How you can see in attached projects, I have worked with a simple examples where I am adding doubles and some arrays and methods that you use in your project, but using my custom DashLine Class. I think this solve your problem and works as you want. Please, can you check this projects in version 4 and version 2 and tell us if it solve your problems of this thread?
TestDashLine.zip
Version 2011
(18.61 KiB) Downloaded 798 times
TestDashLineV2.zip
Version 2
(17 KiB) Downloaded 755 times
4. Is there a way to hide the line that is drawn from series.FirstVisibleIndex-1 to series.FirstVislbeIndex (assuming it exists)
I think you can change the color of concretely segment of line, change its points color to transparent. I think you can do something as next:

Code: Select all

  myCustomLine.Add(1, 5, System.Drawing.Drawing2D.DashStyle.DashDot,"",Color.Transparent);
I hope will helps.

Thanks,
Best Regards,
Sandra Pazos / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

BenW
Advanced
Posts: 119
Joined: Wed Aug 10, 2005 4:00 am

Re: Controlling the linestyle of FirstVisibleIndex-1

Post by BenW » Fri Nov 04, 2011 7:51 pm

Hi Sandra.

I was excited at the prospect of your samples, finaly solving my problem. All your efforts are very much appreciated, however there is one key aspect to the functionality that is being missed, and that relates to the line color. In my set of requirement, the line drawn after the pointer (not before it) must be drawn in the same color as the pointer. This is very important. Definitely, your example doesn't exhibit the line style issue for the line drawn for FirstVisibleindex-1, however it looses the line color functionality as just described. So, if you could provide a solution for that, or offer the option of where I could 'safely' modify the Steema TeeChart source code to make this happen, that would be great. My opinion here is that I believe that the limitation here is that the pointer and line colors/styles cannot be set independently of each other. Does this limitation still exist under V4?

Also the the transparent solution may be a workaround I can use (so that the wrong information is not shown to the user - better to show no data than the wrong data), however I don't think it is possible to explicitly set the color of pointer/line at the FirstVisibleIndex-1 position, explicitly. If there is a way to do this (and likely this needs to be done after the myCustomLine_GetPointerStyle is called and after the internal chart code repaints that particular line), please let me know. Can something be done in the AfterDraw event. Remember, I've already tried to delete and redraw the line (at FirstVisibleIndex-1) in the AfterDraw event, but it seems that the line does not get completly erased (erasing means redrawing the line but in the chart panel background color), and so looks very messy, after it is redrawn (in the AFterDraw event), after the atempted delete. Again, is there some relatively simple Steema TeeChart code change that I can apply locally to my version, that will perhaps help us with this situation? Is there a way to 'cleanly' and completely delete the line drawn at position FirstVisibleIndex-1.

This is the code I tried to use to delete the line from the AfterDraw event:

g.Pen.Width = ((Steema.TeeChart.Styles.Line)s).LinePen.Width;
Rectangle chartRect = g.Chart.ChartRect;
g.ClipRectangle(chartRect);
g.Pen.Color = g.Chart.Panel.Color;
g.Pen.Style = (System.Drawing.Drawing2D.DashStyle)thisSeriesDQLineStyleList[s.XValues.AsDateTime(s.FirstVisibleIndex)];
DNALog.WriteLog(DNALog.LogLevel.Always, "g.Pen.Color prior to delete call: " + g.Pen.Color.ToString() + " g.Pen.Style = " + g.Pen.Style.ToString());
g.Brush.Color = g.Chart.Panel.Color;
System.Drawing.Pen erasePen = new System.Drawing.Pen(g.Chart.Panel.Color);
erasePen.Width = ((Steema.TeeChart.Styles.Line)s).LinePen.Width;
erasePen.DashStyle = (System.Drawing.Drawing2D.DashStyle)thisSeriesDQLineStyleList[s.XValues.AsDateTime(s.FirstVisibleIndex)];
PointF startPoint = new PointF(s.CalcXPos(s.FirstVisibleIndex - 1), s.CalcYPos(s.FirstVisibleIndex - 1));
//PointF endPoint = new PointF(s.CalcXPos(s.FirstVisibleIndex) - (((Steema.TeeChart.Styles.Line)s).Pointer.HorizSize + 1), s.CalcYPos(s.FirstVisibleIndex) - (((Steema.TeeChart.Styles.Line)s).Pointer.HorizSize + 1));
PointF endPoint = new PointF(s.CalcXPos(s.FirstVisibleIndex), s.CalcYPos(s.FirstVisibleIndex) );
g.DrawLine(erasePen, startPoint, endPoint);
//g.Line((s.CalcXPos(s.FirstVisibleIndex - 1)), s.CalcYPos(s.FirstVisibleIndex - 1), s.CalcXPos(s.FirstVisibleIndex), s.CalcYPos(s.FirstVisibleIndex));
g.Pen.Width = ((Steema.TeeChart.Styles.Line)s).LinePen.Width;
g.Pen.Color = (System.Drawing.Color)(thisSeriesDQColorList[s.XValues.AsDateTime(s.FirstVisibleIndex - 1)]);
g.Pen.Style = (System.Drawing.Drawing2D.DashStyle)thisSeriesDQLineStyleList[s.XValues.AsDateTime(s.FirstVisibleIndex - 1)];



Also, please tell me in detailed steps exactly how I can get to, and download the evaluation version of the .NET Steema Teechart V4. My client access only has V2 downloads, and it is not clear to me from the other evaluation versions list that is presented (after I've logged on with my evaluation details), exactly which one I should download (they all seem Delphi /C++ specific and not .NET related).

TeeChart Pro v2011 Evaluation version installers Environment File size

RAD Studio XE (Delphi and C++) 41MB
RAD Studio 2010 (Delphi and C++) 41MB
RAD Studio 2009 (Delphi and C++) 40MB
RAD Studio 2007 (Delphi, C++ and Delphi.Net, Update 3) 62MB

BDS 2006 update 2 and Turbo 2006 versions 62MB
Delphi 2005 update 3 56MB
Delphi 7 update 1 33MB
Delphi 6 update 2 and RTL_update3 33MB
Delphi 5 update 1 33MB
C++ Builder 6 update 4 31MB
C++ Builder 5 update 1 31MB
TeeChart Standard v2011 Evaluation version installers Environment File size

RAD Studio XE (Delphi and C++) 21MB
RAD Studio 2010 (Delphi and C++) 21MB
RAD Studio 2009 (Delphi and C++) 21MB
RAD Studio 2007 (Delphi, C++ and Delphi.Net, Update 3) 28MB

BDS 2006 update 2 and Turbo 2006 versions 27MB
Delphi 2005 update 3 26MB
Delphi 7 update 1 15MB
Delphi 6 update 2 and RTL_update3 15MB
Delphi 5 update 1 15MB
C++ Builder 6 update 4 16MB
C++ Builder 5 update 1 16MB

Release.txt - 8.0 KB
[download]
--------------------------------------------------------------------------------


Version 8 Installers
January 01, 2010
TeeChart Pro v8 Evaluation version installers Environment File size

RAD Studio 2010 (Delphi and C++) 38.3MB
RAD Studio 2009 (Delphi and C++) 37.2MB
RAD Studio 2007 (Delphi, C++ and Delphi.Net, Update 3) 56.1MB

BDS 2006 update 2 and Turbo 2006 versions 56.6MB
Delphi 2005 update 3 51.2MB
Delphi 7 update 1 32.9MB
Delphi 6 update 2 and RTL_update3 32.8MB
Delphi 5 update 1 32.3MB
Delphi 4 update 3 32.4MB

C++ Builder 6 update 4 35.6MB
C++ Builder 5 update 1 33.5MB
C++ Builder 4 update 1

Thank you.
Ben.

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Re: Controlling the linestyle of FirstVisibleIndex-1

Post by Sandra » Mon Nov 07, 2011 4:41 pm

Hello BenW,
I was excited at the prospect of your samples, finaly solving my problem. All your efforts are very much appreciated, however there is one key aspect to the functionality that is being missed, and that relates to the line color. In my set of requirement, the line drawn after the pointer (not before it) must be drawn in the same color as the pointer. This is very important. Definitely, your example doesn't exhibit the line style issue for the line drawn for FirstVisibleindex-1, however it looses the line color functionality as just described. So, if you could provide a solution for that, or offer the option of where I could 'safely' modify the Steema TeeChart source code to make this happen, that would be great. My opinion here is that I believe that the limitation here is that the pointer and line colors/styles cannot be set independently of each other. Does this limitation still exist under V4?
Also the the transparent solution may be a workaround I can use (so that the wrong information is not shown to the user - better to show no data than the wrong data), however I don't think it is possible to explicitly set the color of pointer/line at the FirstVisibleIndex-1 position, explicitly. If there is a way to do this (and likely this needs to be done after the myCustomLine_GetPointerStyle is called and after the internal chart code repaints that particular line), please let me know. Can something be done in the AfterDraw event. Remember, I've already tried to delete and redraw the line (at FirstVisibleIndex-1) in the AfterDraw event, but it seems that the line does not get completly erased (erasing means redrawing the line but in the chart panel background color), and so looks very messy, after it is redrawn (in the AFterDraw event), after the atempted delete. Again, is there some relatively simple Steema TeeChart code change that I can apply locally to my version, that will perhaps help us with this situation? Is there a way to 'cleanly' and completely delete the line drawn at position FirstVisibleIndex-1.
Ok. In version 4 exist the property of GetPointerStyle e.Color that allow you add a determinate color for each pointer of your series. I have made a new code with some modifications to try to meet your requests:

Code: Select all

    public Form1()
        {
            InitializeComponent();
            InitializeChart();
        }
        List<int> valList;
        List<Color> colorList;
        List<System.Drawing.Drawing2D.DashStyle> dslist;
        private void InitializeChart()
        {

            tChart1.Aspect.View3D = false;
            tChart1.Dock = DockStyle.Fill;

         //   DQLine myCustomLine = new DQLine(tChart1.Chart);
            DQLine myCustomLine = new DQLine(tChart1.Chart);
            myCustomLine.LinePen.Width = 3;
            myCustomLine.Pointer.Visible = true;

            myCustomLine.Pointer.Style = Steema.TeeChart.Styles.PointerStyles.DownTriangle;

            myCustomLine.Pointer.Color = Color.Red;
            myCustomLine.ColorEachLine = true;
            myCustomLine.Pointer.HorizSize = 4;
            myCustomLine.Pointer.VertSize = 4;
            myCustomLine.Pointer.Visible = true;
            myCustomLine.LinePen.Width = 3;
            myCustomLine.Marks.Visible = true;
            myCustomLine.Pointer.Pen.Visible = false;
       
            
            // Not 3D!
            this.tChart1.Aspect.View3D = false;
            valList = new List<int>(new int[] {81, 81, 81, 13, 13, 13, 13, 53 });
            colorList = new List<Color>(new Color[] { Color.Red, Color.Green, Color.Blue, Color.HotPink, Color.Black, Color.Purple, Color.Magenta, Color.Cyan });
            dslist = new List<System.Drawing.Drawing2D.DashStyle>(new System.Drawing.Drawing2D.DashStyle[] { System.Drawing.Drawing2D.DashStyle.DashDot, System.Drawing.Drawing2D.DashStyle.DashDot, System.Drawing.Drawing2D.DashStyle.DashDotDot, System.Drawing.Drawing2D.DashStyle.Dot, System.Drawing.Drawing2D.DashStyle.Solid, System.Drawing.Drawing2D.DashStyle.Dot, System.Drawing.Drawing2D.DashStyle.Dash, System.Drawing.Drawing2D.DashStyle.Solid });
            int index = 0;
            foreach (int val in valList)
            {
                myCustomLine.Add(index, val, dslist[index], "", colorList[index]);//,colorList[index],dslist[index] );
                index++;

            }
       
        ((Steema.TeeChart.Styles.Line)this.tChart1.Series[0]).Color = Color.Green;

           myCustomLine.GetPointerStyle += new Steema.TeeChart.Styles.CustomPoint.GetPointerStyleEventHandler(myCustomLine_GetPointerStyle);
           tChart1.Header.Visible = true;
           tChart1.AfterDraw += new Steema.TeeChart.PaintChartEventHandler(tChart1_AfterDraw);
           //Comment it in version 2
            tChart1.Draw(); 
           //Version to use next
           // Bitmap bitmap1 = tChart1.Bitmap;
          
        }
        void tChart1_AfterDraw(object sender, Steema.TeeChart.Drawing.Graphics3D g)
        {
            int i;
            for (i = 0; i < tChart1.Series[0].Count - 1; i++)
            {
                (tChart1.Series[0] as DQLine)[i + 1].Color = colorList[i];

            }
            if (tChart1.Series[0].Count == i)
            {
                (tChart1.Series[0] as DQLine)[i].Color = colorList[i];
            }
        }

        void myCustomLine_GetPointerStyle(Steema.TeeChart.Styles.CustomPoint series, Steema.TeeChart.Styles.GetPointerStyleEventArgs e)
        {// Get the Data Quality lists for this series...
          DQLine dqSeries = series as DQLine;
          
            if (dqSeries != null)
            {

                if (e.ValueIndex != -1)
                {
                   
                    int nextIndex = e.ValueIndex;
                    if (nextIndex < (series.LastVisibleIndex+1))
                    {
                        e.Color = colorList[nextIndex];
                        series.LinePen.Style = dslist[nextIndex];
                    }
                    
                }
            }
        }

On the other hand, this requirement doesn't exist in V2 of TeeChart.Net, but I modified your code to try to works as you want.

Code: Select all

        public Form1()
        {
            InitializeComponent();
            InitializeChart();
        }
        List<int> valList;
        List<Color> colorList;
        List<System.Drawing.Drawing2D.DashStyle> dslist;
        private void InitializeChart()
        {

            tChart1.Aspect.View3D = false;
            tChart1.Dock = DockStyle.Fill;

            //   DQLine myCustomLine = new DQLine(tChart1.Chart);
            DQLine myCustomLine = new DQLine(tChart1.Chart);
            myCustomLine.LinePen.Width = 3;
            myCustomLine.Pointer.Visible = true;

            myCustomLine.Pointer.Style = Steema.TeeChart.Styles.PointerStyles.DownTriangle;

            myCustomLine.Pointer.Color = Color.Red;
            myCustomLine.ColorEachLine = true;
            myCustomLine.Pointer.HorizSize = 4;
            myCustomLine.Pointer.VertSize = 4;
            myCustomLine.Pointer.Visible = true;
            myCustomLine.LinePen.Width = 3;
            myCustomLine.Marks.Visible = true;

            // Not 3D!
            this.tChart1.Aspect.View3D = false;


            valList = new List<int>(new int[] { 81, 81, 81, 13, 13, 13, 13, 53 });
            colorList = new List<Color>(new Color[] { Color.Red, Color.Green, Color.Blue, Color.HotPink, Color.Black, Color.Purple, Color.Magenta, Color.Cyan });
            dslist = new List<System.Drawing.Drawing2D.DashStyle>(new System.Drawing.Drawing2D.DashStyle[] { System.Drawing.Drawing2D.DashStyle.DashDot, System.Drawing.Drawing2D.DashStyle.DashDot, System.Drawing.Drawing2D.DashStyle.DashDotDot, System.Drawing.Drawing2D.DashStyle.Dot, System.Drawing.Drawing2D.DashStyle.Solid, System.Drawing.Drawing2D.DashStyle.Dot, System.Drawing.Drawing2D.DashStyle.Dash, System.Drawing.Drawing2D.DashStyle.Solid });
            int index = 0;
            foreach (int val in valList)
            {
                myCustomLine.Add(index, val, dslist[index], "", colorList[index]);//,colorList[index],dslist[index] );
                index++;

            }
            ((Steema.TeeChart.Styles.Line)this.tChart1.Series[0]).Pointer.Pen.Color = Color.Pink;
            ((Steema.TeeChart.Styles.Line)this.tChart1.Series[0]).Color = Color.Green;

            myCustomLine.GetPointerStyle += new Steema.TeeChart.Styles.CustomPoint.GetPointerStyleEventHandler(myCustomLine_GetPointerStyle);
            tChart1.Header.Visible = true;
            tChart1.AfterDraw += new Steema.TeeChart.PaintChartEventHandler(tChart1_AfterDraw);
            Bitmap bitmap1 = tChart1.Bitmap;
            Bitmap bitmap2 = tChart1.Bitmap;

        }
        void tChart1_AfterDraw(object sender, Steema.TeeChart.Drawing.Graphics3D g)
        {
            int i;
            (tChart1.Series[0] as DQLine).Pointer.Pen.Visible = false;
            for (i = 0; i < tChart1.Series[0].Count - 1; i++)
            {
                (tChart1.Series[0] as DQLine)[i + 1].Color = colorList[i];

            }
            if (tChart1.Series[0].Count == i)
            {
                (tChart1.Series[0] as DQLine)[i].Color = colorList[i];
            }

        }

        void myCustomLine_GetPointerStyle(Steema.TeeChart.Styles.CustomPoint series, Steema.TeeChart.Styles.CustomPoint.GetPointerStyleEventArgs e)
        {// Get the Data Quality lists for this series...
            DQLine dqSeries = series as DQLine;

            if (dqSeries != null)
            {

                if (e.ValueIndex != -1)
                {
                    int nextIndex = e.ValueIndex + 1;
                    if (nextIndex < (series.LastVisibleIndex + 1))
                    {
                        //First add color of segment.
                        series.Pointer.Color = colorList[nextIndex];
                        series.LinePen.Style = dslist[nextIndex];

                    }
                    else if (nextIndex == (series.LastVisibleIndex + 1))
                    {
                        series.Pointer.Color = colorList[series.FirstVisibleIndex];
                        series.LinePen.Style = dslist[series.FirstVisibleIndex];

                    }

                }
            }
        }
Please can you tell us if previous codes works as you expected? When you check 2 code, made for version 2 you can see a limitation with FirstPointer. It is solved in version 4 of TeeChart.Net as you can see in the code I have prepared to 4 version.
Also, please tell me in detailed steps exactly how I can get to, and download the evaluation version of the .NET Steema Teechart V4. My client access only has V2 downloads, and it is not clear to me from the other evaluation versions list that is presented (after I've logged on with my evaluation details), exactly which one I should download (they all seem Delphi /C++ specific and not .NET related).
Ok. To download evaluation project of TeeChart.Net, you can download it here select the box where there is Evaluation Versions, after fill the form. If you have any problems when you try to download the evaluation version, please let me know.

Thanks,
Best Regards,
Sandra Pazos / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

BenW
Advanced
Posts: 119
Joined: Wed Aug 10, 2005 4:00 am

Re: Controlling the linestyle of FirstVisibleIndex-1

Post by BenW » Thu Nov 17, 2011 4:15 am

Hi Sandra.

By leveraging the most recent V2 solution you'd posted, I have managed to overcome the original line style issue -thank you very much!!

We do want to go with V4, but the timing is a little off for us right now. I did manage to download V4 evaluation, though - thanks again.

I do have some more questions.

Question1:
In the new DQLine class,if I do an Add() where, the x (DateTime) value already exists, does it just replace the corresponding y value in the series existing internal Values list?

e.g.

x = DateTime.Now;
y = 20;
int addIndex = Add(x, y, string.Empty, Color.Red);
y=30
addIndex = Add(x,y, string.Empty,Color.Red);

will this result in the y value of 20, being replaced with a value of 30 at the index where x = DateTime.Now ?

Question2:
Also in the following method:

void tChart1_AfterDraw(object sender, Steema.TeeChart.Drawing.Graphics3D g)
{
int i;
(tChart1.Series[0] as DQLine).Pointer.Pen.Visible = false;
for (i = 0; i < tChart1.Series[0].Count - 1; i++)
{
(tChart1.Series[0] as DQLine)[i + 1].Color = colorList;

}
if (tChart1.Series[0].Count == i)
{
(tChart1.Series[0] as DQLine).Color = colorList;
}
}

...what exactly is the purpose of the bold lines of code, and are they necessary?

Regards,
Ben.

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Re: Controlling the linestyle of FirstVisibleIndex-1

Post by Sandra » Mon Nov 21, 2011 4:13 pm

Hello Ben,

Question1
Can you tell us if next code works as you expect?

Code: Select all

DateTime x = DateTime.Now;
          int y = 20;
          myCustomLine.XValues.DateTime = true;
          int addIndex = myCustomLine.Add(x.ToOADate(), y, dslist[0], "", Color.Empty);
          y = 30;
          
          addIndex = myCustomLine.Add(x.ToOADate(), y, dslist[1], "", Color.Empty);
          myCustomLine.YValues[0] = 30;  

Question2:

The code:
if (tChart1.Series[0].Count == i)
{
(tChart1.Series[0] as DQLine).Color = colorList;
} }

Isn't necessary, so if you use the code without previous lines of code, it works fine.


Thanks,

I hope will helps.
Best Regards,
Sandra Pazos / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Post Reply