Issue with Color Band Tool.

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
QL_member
Newbie
Newbie
Posts: 8
Joined: Fri Oct 05, 2012 12:00 am

Issue with Color Band Tool.

Post by QL_member » Thu Feb 07, 2013 12:16 am

Hello,

I am having issue using ColorBand tool, the colorband tools gets really slow (sometimes stuck) while rendering if either of the colorband's edge is editable and is not in the charts viewable region. Please look at the sample code below, look at the Start value of the color band and set its value anything other than the visible reagion of the chart ( e.g change start to -999).

Please also verify if i am using the correct dll version for TeeChart.WPF.dll.( The version i am using is 4.1.2012.9287)

Thanks
Syd.


Code: Select all

using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows;
using System.Windows.Media;
using Steema.TeeChart.WPF;
using Steema.TeeChart.WPF.Functions;
using Steema.TeeChart.WPF.Styles;
using Steema.TeeChart.WPF.Tools;

namespace TChartSample
{
   
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
            DrawChart();
        }

        ColorBand tool;

        // xAxis (x)
        List<PlotValue<DateTime, double?>> xValues = new List<PlotValue<DateTime, double?>>();

        // y1
        List<PlotValue<DateTime, double?>> y1 = new List<PlotValue<DateTime, double?>>();

        List<PlotValue<double?, double?>>[] plotValues = new List<PlotValue<double?, double?>>[2];

        private void DrawChart()
        {
            var axis = new Axis(tc.Chart)
            {
                Title = new AxisTitle { Caption = "TEST", Angle = 90 },
                Visible = true,
                Automatic = true,
                PositionUnits = PositionUnits.Pixels,
                RelativePosition = 0,
                TickOnLabelsOnly = false,
                Labels = { Style = AxisLabelStyle.Auto },

            };
            
            // Set Chart props
            tc.Axes.Bottom.Automatic = true;
            tc.Axes.Bottom.Labels.DateTimeFormat = string.Empty;
            tc.Axes.Bottom.Labels.ValueFormat = string.Empty;
            tc.Aspect.View3D = false;
            tc.Legend.Visible = false;
            tc.Zoom.Allow = true;
            tc.Zoom.Direction = ZoomDirections.Horizontal;
            
            #region Series1

            var pointSeries1 = new Points(tc.Chart);
            pointSeries1.Title = "pxPoint1";
            pointSeries1.TreatNaNAsNull = true;
            pointSeries1.TreatNulls = TreatNullsStyle.DoNotPaint;
            pointSeries1.Function = new DownSampling(tc.Chart) { Method = DownSamplingMethod.MinMaxFirstLastNull };
            pointSeries1.Color = Colors.Tomato;
            pointSeries1.Pointer.Style = PointerStyles.Rectangle;
            

            // xAxis (x)
            xValues = GetValues(DateTime.Now.Date, 1, 20);

            // y1
            y1 = GetValues(DateTime.Now.Date, 1, 40);

            plotValues[0] = GetPlotValues(xValues, y1);

            pointSeries1.Add(plotValues[0].Select(x => x.X).ToArray(), plotValues[0].Select(x => x.Y).ToArray());

            pointSeries1.CheckDataSource();

            pointSeries1.CustomVertAxis = axis;

            #endregion
            
            tc.Axes.Custom.Add(axis);

            #region ColorBand Tool

            tool = new ColorBand(tc.Chart);
            tc.Tools.Add(tool);

            tool.Axis = axis;

            tool.ResizeEnd = true;
            tool.ResizeStart = true;


            // This is creating issue when either start or end is out of visible region of the chart.
            tool.Start = 5;
            tool.End = 20;
          

            #endregion

        }
       

        public List<PlotValue<DateTime, double?>> GetValues(DateTime sDateTime, int randomMinValue, int randomMaxValue)
        {
            var random = new Random();

            var values = new List<PlotValue<DateTime, double?>>();

            for (int i = 0; i < 10; i++)
            {
                values.Add(new PlotValue<DateTime, double?> { X = sDateTime, Y =  random.Next(randomMinValue, randomMaxValue) });

                sDateTime = sDateTime.AddMinutes(1);
            }

            return values;
        }

        private List<PlotValue<double?, double?>> GetPlotValues(IEnumerable<PlotValue<DateTime, double?>> xValues, List<PlotValue<DateTime, double?>> yValues)
        {
            var plotValues = new List<PlotValue<double?, double?>>();

            foreach (var xVal in xValues)
            {
                double? y = yValues.Find(v => v.X == xVal.X).Y;

                plotValues.Add(new PlotValue<double?, double?> { X = xVal.Y, Y = y });

            }

            return plotValues;
        }
        
    }

    public class PlotValue<T1, T2>
    {
        public T1 X { get; set; }
        public T2 Y { get; set; }
    }

}

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

Re: Issue with Color Band Tool.

Post by Sandra » Thu Feb 07, 2013 4:22 pm

Hello Andy,

Seems this problem occurs in latest version of TeeChartFor.Net too. We consider it as a bug with number [TW16016505]. We will try to fix it for next maintenance releases of TeeChartFor.Net.


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

QL_member
Newbie
Newbie
Posts: 8
Joined: Fri Oct 05, 2012 12:00 am

Re: Issue with Color Band Tool.

Post by QL_member » Thu Feb 07, 2013 8:33 pm

Hello Sandra,

Do you know when are we expecting this issue to re resolved? Our release is depdendent on this fix.

Thanks
Syd.

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

Re: Issue with Color Band Tool.

Post by Sandra » Fri Feb 08, 2013 12:08 pm

Hello Andy,

I can not provide you an estimate date, because the last maintenance release is published in 31 of January 2013. I recommend you to be aware at this forum, our RSS news feed, twitter and facebook accounts for new release announcements and what's implemented on them.

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

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

Re: Issue with Color Band Tool.

Post by Sandra » Wed Feb 27, 2013 10:44 am

Hello Andy,

After had made many tests, I inform you, we can't think on a way to fix this without breaking other TeechartWpf functionalities, therefore we can't fix the bug. On the other hand, to solve your problem we have found a simple workaround that allow you work in correct way without problems.

Code: Select all

       Steema.TeeChart.WPF.Tools.ColorBand tool;
        private void InitializeChart()
        {
            tChart1.Aspect.View3D = false;
            Steema.TeeChart.WPF.Styles.Points points = new Points(tChart1.Chart);
            Random rnd = new Random();
            for (int i = 0; i < 10; i++)
            {
                points.Add(i, rnd.Next(100));
            }

            tool = new ColorBand(tChart1.Chart);
            tChart1.Axes.Visible = false;
            tool.Axis = tChart1.Axes.Left;
            tool.ResizeEnd = true;
            tool.Start = -999;
            tool.End = 50;
            tChart1.BeforeDraw += tChart1_BeforeDraw;

        }
        void tChart1_BeforeDraw(object sender, Graphics3D g)
        {
            if (tool.Start >= tool.Axis.Minimum && tool.End <= tool.Axis.Maximum) tool.ResizeStart = true;

        }
Could you confirm us if previous problem works in your end?

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

Post Reply