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.
Hello Cheruvelil,
I moved your last question to a separate thread:
Lines are drawn incorrectly when markers are enabled
Please refer to this report for further correspondence on this item. As for your code, would you please clarify your final goal? Why do you need to enable and disable zooming? A full description will help us find the best solution for you. I hope to hear from you soon.
follow these steps to reproduce the issue
add a series using the button
then zoom in a bit
then remove the series
and then add a series again
also try the same steps but skip zooming in part …
Cheruvelil,
I got your sample and would also like to understand your final goal of this scrolling/zooming code. Why do you need to change the EnableAxisYZooming and Auto properties in this scenario? What kind of behavior do you expect to get? I hope to hear from you soon.
I just need to enable zoom and to my understanding Zooming is not enabled by default.
if you look at the code attached (the one that I attached in the reply) the EnableAxisYZooming it just there to enable the zooming on the chart control when I add the first series.
I am trying to change the "Auto properties" as I read somewhere in you tickets that to reset the zoom I need to set this value to true and it will reset the zoom on the chartControl (I am doing this because I am facing the issue of automatic-full-zoom when a new series is added)
If you try to run the code that I attached you will notice that the issue is there.
what I am trying to achieve is allowing the user to make charts on runtime and from a datagrid.
the user enters some formula and my code generates some data for a series. I want to display that in a chart so I add a series.
the user might not like the chart and he might want to remove this chart so I gave him the option to remove the series.
and I want the zooming and scrolling to be enabled throughout BUT then I face the issue that can be reproduced from sample Code that I gave you
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:
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.
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.
the site is not showing the 'mark as answer' button. Please mark you last reply as answer and close this ticket.
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.