Page 1 of 1
Legend Checkbox
Posted: Thu Jul 16, 2009 12:52 pm
by 9640703
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
Re: Legend Checkbox
Posted: Thu Jul 16, 2009 3:13 pm
by yeray
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;
}
}
}
Re: Legend Checkbox
Posted: Thu Jul 16, 2009 6:37 pm
by 9640703
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
Re: Legend Checkbox
Posted: Fri Jul 17, 2009 11:27 am
by yeray
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.
Re: Legend Checkbox
Posted: Fri Jul 17, 2009 2:11 pm
by 9640703
Thanks for the quick ply. This is exactly what I was looking for.
Thanks,
Sachin
Axes labels questions
Posted: Fri Jul 17, 2009 10:08 pm
by 9640703
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 (15.35 KiB) Viewed 11792 times
- labels_dispplayhed.JPG (22.44 KiB) Viewed 11793 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
Re: Legend Checkbox
Posted: Mon Jul 20, 2009 8:53 am
by 10050769
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,
Re: Legend Checkbox
Posted: Wed Jul 22, 2009 2:36 pm
by 9640703
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
Re: Legend Checkbox
Posted: Thu Jul 23, 2009 9:28 am
by 10050769
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,