Ticket T290765
Visible to All Users

XtraChart auto zoom issue

created 9 years ago (modified 9 years ago)

I am using the xtrachart control to make some plots.

in a while loop I add some points

C#
seriesPoint = new DevExpress.XtraCharts.SeriesPoint(worksheet.Cells[row, columIndexX].Value.DateTimeValue,  new object[] { worksheet.Cells[row, columIndexY].Value.NumericValue }); above is how I create the points.

after adding the points to the series

C#
DevExpress.XtraCharts.Series series = new DevExpress.XtraCharts.Series(); series.CrosshairEnabled = DevExpress.Utils.DefaultBoolean.True; series.CrosshairLabelVisibility = DevExpress.Utils.DefaultBoolean.True; series.ArgumentScaleType = DevExpress.XtraCharts.ScaleType.Auto; series.ChangeView(DevExpress.XtraCharts.ViewType.Spline); series.Name = textBox4.Text; DevExpress.XtraCharts.LineSeriesView lsv = (DevExpress.XtraCharts.SplineSeriesView)(series.View); //lsv.ColorEach = true; lsv.LineStyle.DashStyle = DevExpress.XtraCharts.DashStyle.Solid; lsv.LineStyle.Thickness = 3; lsv.MarkerVisibility = DevExpress.Utils.DefaultBoolean.True; //series.ValueScaleType = DevExpress.XtraCharts.ScaleType.Auto; series.Label.Antialiasing = true; series.LegendText = textBox4.Text; DevExpress.XtraCharts.SeriesPoint seriesPoint = new DevExpress.XtraCharts.SeriesPoint();

this is how I create a new series
series.Points.Add(seriesPoint);
I add this series to a chartControl1(XtraChatControl)

C#
var diag = (DevExpress.XtraCharts.XYDiagram)chartControl1.Diagram; if (diag != null) {     if (chartControl1.Series.Count == 0)     {         diag.EnableAxisYZooming = false;         diag.EnableAxisXZooming = false;        diag.EnableAxisXScrolling = false;         diag.EnableAxisYScrolling = false;     } } chartControl1.Series.Add(series); if (diag != null) {     if (!diag.IsZoomingEnabled)     {         diag.EnableAxisYZooming = true;         diag.EnableAxisXZooming = true;      diag.AxisY.VisualRange.Auto = true;      diag.AxisX.VisualRange.Auto = true;     }     if (!diag.IsScrollingEnabled)     {         diag.EnableAxisXScrolling = true;         diag.EnableAxisYScrolling = true;     } }

when I add one series like this … the diag is null. even just after adding the series
so both conditions blocks dont work

when I do this again and add another series , this time the diag is not null (I think diag is getting value after the series is printed or on some other even later on , not on chart.Series.Add(series))

I am attaching some images in a zip file as you dont allow multiple attachments

when I add the first series , I cant Zoom(since the chat.Diagram is null just after adding the series)
Note: initially my chatControl has no XYDiagram assigned to it and I am not assigning it at any point

when I add the second series then I can zoom and scroll (the chart did have a Diagram this time as it was supposed to)

The issue comes when I remove all the series and add a series back

now
if( Zoom_Level_Before_removing_last_series() !=0 )
    then the new series that is added is shown with maximum zoom
    and its takes quite some time to zoom out manually.

so basically I have two questions … how to enable zoom when the first series is added
and if the last series removed was removed when the control Zoom was not zero then how to add a new series with zero zoom, or reset zoom when adding the first series(I cannot access charControl.Diagram as its null just after adding the series)

If there is any ambiguity in my question please ask and I would try to elaborate .

PS
First Image is with single series added
Second image shows the state of the control when a new series was added (all series were first removed, so the chart had no series before this) this is the Zoom issue that I am facing.
third image is me trying to zoom out (apparently the x axis zooms out first, then the y axis starts to zoom out, whereas the zoom in works on both simultaneously)
fourth image is me still trying to zoom out

PPS
something else I found while using this control , when the point markers are enabled and the Series style is Line then the Lines do not end at points, they go a bit above and beyond. is this a issue ? this surely is misleading for a graph.

Show previous comments (6)
CJ CJ
Cheruvelil Jayaprakash 9 years ago

    Changed my code and it works now. though you might want to change the default behavior of the chartControl or document it somewhere.
    thanks
    marking this as solved.

    CJ CJ
    Cheruvelil Jayaprakash 9 years ago

      the site is not showing the 'mark as answer' button. Please mark you last reply as answer and close this ticket.

      DevExpress Support Team 9 years ago

        I am happy to hear that my assistance was useful to you. I have moved my last comment to the answer section, so you can mark this issue as solved. Feel free to contact us if you have more questions.

        Answers approved by DevExpress Support

        created 9 years ago (modified 9 years ago)

        Moved from the comments section
        Thank you for your clarification Cheruvelil.
        Now it is clear. Yes, your approach to reset zooming is correct (using the Range.Auto property). Please check the attached sample. I have used version 14.2.7 and 15.1.4 (mentioned in this thread) with your sample and steps. As you can see, the diag variable is not null. However the second condition does not work properly. I suggest that you modify you code in the following manner:

        C#
        private void button2_Click(object sender, EventArgs e) {     CurrentViewType = ViewType.Line;     Series series = new Series();     series.CrosshairEnabled = DevExpress.Utils.DefaultBoolean.True;     series.CrosshairLabelVisibility = DevExpress.Utils.DefaultBoolean.True;     series.ArgumentScaleType = DevExpress.XtraCharts.ScaleType.Auto;     series.ChangeView(DevExpress.XtraCharts.ViewType.Line);     series.Name = "plot " + (p1++).ToString();     LineSeriesView lsv = (LineSeriesView)(series.View);     lsv.LineStyle.DashStyle = DevExpress.XtraCharts.DashStyle.Solid;     lsv.LineStyle.Thickness = 3;     lsv.MarkerVisibility = DevExpress.Utils.DefaultBoolean.True;     series.Label.Antialiasing = true;     series.LegendText = "plot" + (p1++).ToString();     CreateData(series, 100);     chartControl1.Series.Add(series);     var diag = (XYDiagram)chartControl1.Diagram;     if (diag != null)     {         diag.EnableAxisYZooming = true;         diag.EnableAxisXZooming = true;         diag.EnableAxisXScrolling = true;         diag.EnableAxisYScrolling = true;         diag.AxisY.VisualRange.Auto = true;         diag.AxisX.VisualRange.Auto = true;     } }

        I have attached the modified sample.

          Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

          Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.