TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
-
abuniz
- Newbie
- Posts: 3
- Joined: Tue Apr 24, 2012 12:00 am
Post
by abuniz » Tue May 01, 2012 3:02 am
Hello,
I am working with Steema TeeChart for iOS (Monotouch) and I am trying to get limit the panning of the Chart past the data points. My x-axis is a DateTime and my panning is set to horizontal only:
Code: Select all
_chart.Header.Text = string.Format("{0} consumption usage", _resolution);
_chart.Axes.Bottom.Labels.DateTimeFormat = "d";
_chart.Axes.Bottom.Labels.Font.Size = 8;
_chart.Axes.Bottom.Labels.Angle = 0;
_chart.Axes.Bottom.Labels.Style = AxisLabelStyle.Value;
_chart.Axes.Left.Title.Text = "Consumption";
_chart.Axes.Left.Title.TextAlign = MonoTouch.CoreText.CTTextAlignment.Center;
_chart.Legend.Visible = false;
_chart.Aspect.View3D = false;
_chart.Aspect.ZoomScrollStyle = Steema.TeeChart.Drawing.Aspect.ZoomScrollStyles.Manual;
_chart.Panning.Allow = ScrollModes.Horizontal;
Steema.TeeChart.Themes.ExcelTheme theme = new Steema.TeeChart.Themes.ExcelTheme(_chart.Chart);
theme.Apply();
_chart.ScrollMod += Handle_chartScrollMod;
_chart.Zoomed += Handle_chartZoomed;
_chart.UndoneZoom += Handle_chartUndoneZoom;
I am looking for help to put code to not allow me to pan past my data limit. I set pages with maximum data points per page and the panning works but I would like to stop after the data points are done.
-
Sandra
- Site Admin
- Posts: 3132
- Joined: Fri Nov 07, 2008 12:00 am
Post
by Sandra » Wed May 02, 2012 1:50 pm
Hello abuniz,
I have made a simple code where I am limiting the scroll in the horizontal axes.
Code: Select all
public Form1()
{
InitializeComponent();
InitializeChart();
}
private void InitializeChart()
{
tChart1.Axes.Bottom.Labels.DateTimeFormat = "d";
tChart1.Axes.Bottom.Labels.Font.Size = 8;
tChart1.Axes.Bottom.Labels.Angle = 0;
tChart1.Axes.Bottom.Labels.Style = AxisLabelStyle.Value;
tChart1.Axes.Left.Title.Text = "Consumption";
tChart1.Legend.Visible = false;
tChart1.Aspect.View3D = false;
tChart1.Panning.Allow = ScrollModes.Horizontal;
Steema.TeeChart.Styles.Line line1 = new Line(tChart1.Chart);
line1.FillSampleValues(100);
tChart1.Scroll += new EventHandler(tChart1_Scroll);
Steema.TeeChart.Themes.ExcelTheme theme = new Steema.TeeChart.Themes.ExcelTheme(tChart1.Chart);
theme.Apply();
tChart1.UndoneZoom += new EventHandler(tChart1_UndoneZoom);
}
void tChart1_Scroll(object sender, EventArgs e)
{
if (tChart1.Axes.Bottom.Minimum < 0)
{
tChart1.Axes.Bottom.AutomaticMinimum = false;
tChart1.Axes.Bottom.Minimum = 0;
tChart1.Axes.Bottom.AutomaticMaximum = false;
tChart1.Axes.Bottom.Maximum = tChart1[0].MaxXValue();
}
if (tChart1.Axes.Bottom.Maximum > tChart1[0].XValues.Maximum)
{
tChart1.Axes.Bottom.AutomaticMinimum = false;
tChart1.Axes.Bottom.Minimum = tChart1[0].XValues.Maximum;
tChart1.Axes.Bottom.AutomaticMaximum = false;
tChart1.Axes.Bottom.Maximum = 0;
}
}
void tChart1_UndoneZoom(object sender, EventArgs e)
{
tChart1.Axes.Bottom.Automatic = true;
}
As you see, the previous code is made for an application of Winforms, but you can do the same in TeeChartForIOs(Monotouch). Can you tell if previous code works as you expect?
I hope will helps.
Thanks,
-
abuniz
- Newbie
- Posts: 3
- Joined: Tue Apr 24, 2012 12:00 am
Post
by abuniz » Wed May 02, 2012 2:19 pm
Hey Sandra,
thanks for your reply but that code did not work as expected. When panning to the left (below minimum data) nothing happens. I can still pan all the way past any data. When panning to the right (above maximum data) all my bars get stacked on top of each other. I used your code and modified it a bit and got it working (below):
Code: Select all
void Handle_chartScroll (object sender, EventArgs e)
{
if (_chart.Axes.Bottom.Minimum < _chart[0].XValues.Minimum)
{
_chart.Axes.Bottom.AutomaticMinimum = false;
_chart.Axes.Bottom.AutomaticMaximum = false;
DateTime dt = Steema.TeeChart.Utils.DateTime(_chart[0].XValues.Minimum);
switch (_resolution)
{
case "Monthly":
_chart.Axes.Bottom.SetMinMax(dt, dt.AddMonths(6));
break;
case "Daily":
_chart.Axes.Bottom.SetMinMax(dt, dt.AddDays(6));
break;
case "Hourly":
_chart.Axes.Bottom.SetMinMax(dt, dt.AddHours(6));
break;
default:
break;
}
}
if (_chart.Axes.Bottom.Maximum > _chart[0].XValues.Maximum)
{
_chart.Axes.Bottom.AutomaticMinimum = false;
_chart.Axes.Bottom.AutomaticMaximum = false;
DateTime dt = Steema.TeeChart.Utils.DateTime(_chart[0].XValues.Maximum);
switch (_resolution)
{
case "Monthly":
_chart.Axes.Bottom.SetMinMax(dt.AddMonths(-6), dt);
break;
case "Daily":
_chart.Axes.Bottom.SetMinMax(dt.AddDays(-6), dt);
break;
case "Hourly":
_chart.Axes.Bottom.SetMinMax(dt.AddHours(-6), dt);
break;
default:
break;
}
}
}
-
Sandra
- Site Admin
- Posts: 3132
- Joined: Fri Nov 07, 2008 12:00 am
Post
by Sandra » Thu May 03, 2012 11:38 am
Hello abuniz,
Can you attached here a simple code where your problem occurs because we can try to reproduce exactly it here?
Thanks,