Legend Checkbox

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
gs
Newbie
Newbie
Posts: 84
Joined: Mon Mar 20, 2006 12:00 am
Location: US

Legend Checkbox

Post by gs » Thu Jul 16, 2009 12:52 pm

For my chart I needed legend checkbox to be in a pop floating window and not integrated with the chart as in the chart samples to avoid space used by it .
Is it doable?

Thanks,
Sachin

Yeray
Site Admin
Site Admin
Posts: 9614
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Legend Checkbox

Post by Yeray » Thu Jul 16, 2009 3:13 pm

Hi Sachin,

Yes, for example you could use OnMouseClick event to show and hide the legend in combination with OnMouseMove event to retrieve the position to draw it:

Code: Select all

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

        FastLine fast1, fast2, fast3;
        int MouseX, MouseY;

        private void InitializeChart()
        {
            chartController1.Chart = tChart1;

            tChart1.Aspect.View3D = false;
            tChart1.Legend.Visible = false;

            fast1 = new FastLine(tChart1.Chart);
            fast2 = new FastLine(tChart1.Chart);
            fast3 = new FastLine(tChart1.Chart);

            fast1.FillSampleValues(100);
            fast2.FillSampleValues(100);
            fast3.FillSampleValues(100);

            tChart1.Legend.CheckBoxes = true;
            tChart1.Click += new EventHandler(tChart1_Click);
            tChart1.MouseMove += new MouseEventHandler(tChart1_MouseMove);
        }

        void tChart1_MouseMove(object sender, MouseEventArgs e)
        {
            MouseX = e.X;
            MouseY = e.Y;
        }

        void tChart1_Click(object sender, EventArgs e)
        {
            if (tChart1.Legend.Clicked(MouseX, MouseY) == -1)
            {
                if (tChart1.Legend.Visible) tChart1.Legend.Visible = false;
                else
                {
                    tChart1.Legend.Visible = true;
                    tChart1.Legend.CustomPosition = true;
                    tChart1.Legend.Left = MouseX;
                    tChart1.Legend.Top = MouseY;
                }
            }
        }
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

gs
Newbie
Newbie
Posts: 84
Joined: Mon Mar 20, 2006 12:00 am
Location: US

Re: Legend Checkbox

Post by gs » Thu Jul 16, 2009 6:37 pm

Hi Yeray ,

What I needed was chart will be on main panel & on click of a menu. A form pops up & the legend be the child to that popup form which user can move around or close whenever needed rather than appearing on the chart screen itself.

Thanks,
Sachin

Yeray
Site Admin
Site Admin
Posts: 9614
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Legend Checkbox

Post by Yeray » Fri Jul 17, 2009 11:27 am

Hi Sachin,

Then I think that what you are looking for is the ChartListBox component. Take a look at the demo at All features\Welcome !\Components\Chart listbox. You'll find demos and tutorials at TeeChart programs group.
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

gs
Newbie
Newbie
Posts: 84
Joined: Mon Mar 20, 2006 12:00 am
Location: US

Re: Legend Checkbox

Post by gs » Fri Jul 17, 2009 2:11 pm

Thanks for the quick ply. This is exactly what I was looking for.

Thanks,
Sachin

gs
Newbie
Newbie
Posts: 84
Joined: Mon Mar 20, 2006 12:00 am
Location: US

Axes labels questions

Post by gs » Fri Jul 17, 2009 10:08 pm

I have 2 questions about axes labels

1) Displaying Datetime labels on bottom axes when time range is in millisecs.

settings for axes
chart.Axes.Bottom.Labels.DateTimeFormat = "HH:mm:ss:fff";
chart.Axes.Bottom.Increment = (double)DateTimeSteps.OneMillisecond;

The datetime are not displayed in this scenario. It is displayed when time range is in secs or more. I am attaching the screenshots
missing_labels.JPG
missing_labels.JPG (15.35 KiB) Viewed 11743 times
labels_dispplayhed.JPG
labels_dispplayhed.JPG (22.44 KiB) Viewed 11744 times
2) second question. On Y axes I want to display axis labels at the points only on the series & not equal division of the axess. I tried doing this by handling getaxes label. As seen in the image this avoids displaying labels on axes but blank ticks are still visible.

Axis axes = chart.Axes.Custom[0];
if (sender.Equals(axes))
{
double tmp = Convert.ToDouble(e.LabelText);
for (int i = 0; i < chart.Series.Count; i++)
{
Series series = chart.Series;
if(series.YValues.IndexOf(tmp) != -1)
{
e.LabelText = tmp.ToString();
break;
}
else
{
double val = tmp;
e.LabelText = string.Empty;

}

}


Thanks,
Sachin

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

Re: Legend Checkbox

Post by Sandra » Mon Jul 20, 2009 8:53 am

Hello Sachin,
1) Displaying Datetime labels on bottom axes when time range is in millisecs.
When you want to increment values in axes with DatetimeFormat, you must use next lines of code, why works fine. Because this chart.Axes.Bottom.Increment = (double)DateTimeSteps.OneMillisecond, isn't correct.

Code: Select all

   
            tChart1.Axes.Bottom.Labels.DateTimeFormat = "hh:mm:ss:ff";
            tChart1.Axes.Bottom.Increment = Steema.TeeChart.Utils.GetDateTimeStep(Steema.TeeChart.DateTimeSteps.OneMillisecond);
2) second question. On Y axes I want to display axis labels at the points only on the series & not equal division of the axess. I tried doing this by handling getaxes label. As seen in the image this avoids displaying labels on axes but blank ticks are still visible.
If you want to hide Ticks, and minorTick, of your chart only you do next lines of code for your custom axes:

Code: Select all

           axes.Ticks.Visible = false;
           axes.MinorTicks.Visible = false;
I hope that 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

gs
Newbie
Newbie
Posts: 84
Joined: Mon Mar 20, 2006 12:00 am
Location: US

Re: Legend Checkbox

Post by gs » Wed Jul 22, 2009 2:36 pm

2) second question. On Y axes I want to display axis labels at the points only on the series & not equal division of the axess. I tried doing this by handling getaxes label. As seen in the image this avoids displaying labels on axes but blank ticks are still visible.


If you want to hide Ticks, and minorTick, of your chart only you do next lines of code for your custom axes:


Basically what I was looking was, I needed axis to be labelled at all the YValues which corresponds to the series points and not equal division provide by TChart.

for eg. my series is drawn over ponts (10.0, 10.1, 10.5) Yvalues I needed this values to be labels on axes and not (10.0, 10.2, 10.4, 10.6) provided bu chart.

Thanks,
Sachin

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

Re: Legend Checkbox

Post by Sandra » Thu Jul 23, 2009 9:28 am

Hello gs,
2) second question. On Y axes I want to display axis labels at the points only on the series & not equal division of the axess. I tried doing this by handling getaxes label. As seen in the image this avoids displaying labels on axes but blank ticks are still visible.
If you want to hide Ticks, and minorTick, of your chart only you do next lines of code for your custom axes:
I'm sorry, I think that next is that if you want to do, please see next code and check that works with you want in your application.

Code: Select all

        private Steema.TeeChart.Styles.Line line;
        private void InitializeChart()
        {
            tChart1.Aspect.View3D = false;
            tChart1.Dock = DockStyle.Fill;
            line = new Steema.TeeChart.Styles.Line(tChart1.Chart);

            Random y = new Random();
            for (int i = 0; i < 10; i++)
            {
                double val = y.Next(100);
                line.Add(val, val.ToString());
            }
            line.XValues.DateTime = true;

            //-----------------------DATE TIME----------------------------------------//
            tChart1.Axes.Bottom.Labels.DateTimeFormat = "hh:mm:ss:ff";
            tChart1.Axes.Bottom.Labels.Angle = 90;
            tChart1.Axes.Bottom.Increment = Steema.TeeChart.Utils.GetDateTimeStep(Steema.TeeChart.DateTimeSteps.OneMillisecond);
         
         //-------------------------CUSTOM AXES-------------------------------------//  
           Steema.TeeChart.Axis axes = new Steema.TeeChart.Axis(tChart1.Chart);
           line.CustomVertAxis = axes;
           tChart1.Axes.Custom.Add(axes);
           axes.Labels.Style = Steema.TeeChart.AxisLabelStyle.Text;
           tChart1.Panel.MarginLeft = 10;
           axes.MinorTicks.Visible = false;
        }
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

Post Reply