Click here to Skip to main content
11,490,282 members (34,170 online)
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# Windows Chart
I m working on data visualization Chart Control i m new in this . i have create one Chart Which Consist three chart area Chart Area1 ,SublineChart and IntersectlineChart Area

//For sub line drawing.
                        subLineChartArea = new ChartArea("subLineChartArea");
                        subLineChartArea.Position = elementPosition;
                        subLineChartArea.InnerPlotPosition = elementPosition;
                        subLineChartArea.BackColor = Color.Transparent;
                        //X&Y properties.
                        subLineChartArea.AxisX.Minimum = (double)Math.Round(minXValue, 2);
                        if (Math.Round(maxXValue, 2) > 0)
                            subLineChartArea.AxisX.Maximum = (double)Math.Round(maxXValue, 2);
                        else
                            subLineChartArea.AxisX.Maximum = maxXValue;
                        subLineChartArea.AxisY.Interval = (double)Math.Round(intensityGraphSettings.MajorTickMarksYValue, 2);
                        subLineChartArea.AxisY.Maximum = (double)Math.Round(maxYValue, 2);
                        subLineChartArea.AxisY.Minimum = (double)Math.Round(minYValue, 2);
                        subLineChartArea.AxisY.TitleAlignment = StringAlignment.Center;
                        subLineChartArea.AxisY.TextOrientation = TextOrientation.Auto;
 
                        subLineChartArea.AxisX.Interval = (double)Math.Round(intensityGraphSettings.MajorTickMarksXValue, 2);
                        subLineChartArea.AxisX.Maximum = (double)Math.Round(maxXValue, 2);
                        subLineChartArea.AxisX.Minimum = (double)Math.Round(minXValue, 2);
 
                        subLineChartArea.AxisX.IntervalAutoMode = IntervalAutoMode.FixedCount;
                        subLineChartArea.AxisX.IntervalType = DateTimeIntervalType.Number;
                        subLineChartArea.AxisX.Interval = (double)Math.Round(intensityGraphSettings.MajorTickMarksXValue, 2);
                        subLineChartArea.AxisX.MinorTickMark.Enabled = true;
                        subLineChartArea.AxisX.MinorTickMark.Interval = (double)Math.Round(intensityGraphSettings.MinorTickMarksXValue, 2);
                        foreach (Axis axis in subLineChartArea.Axes)
                        {
                            axis.Enabled = AxisEnabled.False;
                        }
 
                        intensityGraph.ChartAreas.Add(subLineChartArea);


Above Code Represent how to make intersect lines , While i Zoom this chart it working Fine but my problem is that whenever I scroll The the Chart All lines are moving accept intersect lines. i checked the points of Subline Series and Scale view Size and postion of all the chart Area is same.

Below are the Zoom Code

try
            {
                
                intensityGraph.ChartAreas[0].AxisX.LabelStyle.Format = "N0";
                intensityGraph.ChartAreas[0].AxisY.LabelStyle.Format = "N0";
 
                //Change scrollbar colors   
                intensityGraph.ChartAreas[0].AxisX.ScrollBar.BackColor = Color.LightGray;
                intensityGraph.ChartAreas[0].AxisX.ScrollBar.ButtonColor = Color.LightSteelBlue;
                intensityGraph.ChartAreas[0].AxisX.ScrollBar.LineColor = Color.DarkBlue;
                intensityGraph.ChartAreas[0].AxisX.ScrollBar.ButtonStyle = ScrollBarButtonStyles.All;
 
                intensityGraph.ChartAreas[0].AxisY.ScrollBar.BackColor = Color.LightGray;
                intensityGraph.ChartAreas[0].AxisY.ScrollBar.ButtonColor = Color.LightSteelBlue;
                intensityGraph.ChartAreas[0].AxisY.ScrollBar.LineColor = Color.DarkBlue;
                intensityGraph.ChartAreas[0].AxisY.ScrollBar.ButtonStyle = ScrollBarButtonStyles.All;
 
                if (XScaleSize == 0)
                {
                    intensityGraph.ChartAreas[0].AxisX.ScaleView.Size = intensityGraph.ChartAreas[0].AxisX.ScaleView.ViewMaximum - intensityGraph.ChartAreas[0].AxisX.ScaleView.ViewMinimum;
                    XScaleSize = intensityGraph.ChartAreas[0].AxisX.ScaleView.ViewMaximum - intensityGraph.ChartAreas[0].AxisX.ScaleView.ViewMinimum;
                    XScaleMinSize = XScaleSize;
                    //Maximium Zoom Size 1000% for X Axis
                    XScaleMaxSize = XScaleSize / 10;
                    XScaleSizeFirstvalue = XScaleSize / 1.25;
                }
 
                if (XScaleSize > XScaleMaxSize)
                {
                    intensityGraph.ChartAreas[0].AxisX.ScaleView.Size = XScaleSize / 1.25;
                    intensityGraph.ChartAreas[1].AxisX.ScaleView.Size = XScaleSize / 1.25;
                    intensityGraph.ChartAreas[2].AxisX.ScaleView.Size = XScaleSize / 1.25;
 
                    XScaleSize = XScaleSize / 1.25;
                }
 
                // Zoom In On the Basis of Y Axis

                if (YScaleSize == 0)
                {
 
                    intensityGraph.ChartAreas[0].AxisY.ScaleView.Size = intensityGraph.ChartAreas[0].AxisY.ScaleView.ViewMaximum - intensityGraph.ChartAreas[0].AxisY.ScaleView.ViewMinimum;
                    YScaleSize = intensityGraph.ChartAreas[0].AxisY.ScaleView.ViewMaximum - intensityGraph.ChartAreas[0].AxisY.ScaleView.ViewMinimum;
                    YScaleMinSize = YScaleSize;
                    //Maximum Zoom Size 1000% for Y Axis
                    YScaleMaxSize = YScaleSize / 10;
                    YScaleSizeFirstvalue = YScaleSize / 1.25;
                }
 
                if (YScaleSize > YScaleMaxSize)
                {
                    intensityGraph.ChartAreas[0].AxisY.ScaleView.Size = YScaleSize / 1.25;
                    intensityGraph.ChartAreas[1].AxisY.ScaleView.Size = YScaleSize / 1.25;
                    intensityGraph.ChartAreas[2].AxisY.ScaleView.Size = YScaleSize / 1.25;
 
                    YScaleSize = YScaleSize / 1.25;
                }
 
                intensityGraph.ChartAreas[1].AxisX.ScaleView.Position = intensityGraph.ChartAreas[0].AxisX.ScaleView.Position;
                intensityGraph.ChartAreas[2].AxisX.ScaleView.Position = intensityGraph.ChartAreas[0].AxisX.ScaleView.Position;
 
                //Draw the sub lines.
                DrawSubLinesOnGraph(SubLineDrawType.All);
 
                //Draw the intersect line.
                DrawIntersectLineOnGraph();
 
            }
            catch (Exception ex)
            {
                MessageBox.Show(Properties.Resources.IG_Error_While_ZoomIn_Chart, Properties.Resources.Application_Title, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

Please suggest Me why Only Sublines series not moving correctly while the datapoints
are same .i m unable to Add Picutre of graph here u can see it

http://social.msdn.microsoft.com/Forums/en-US/MSWinWebChart/thread/a888f1ed-4254-47ce-a26e-cb6a86815324[^][]


Thanks
Shashank Tyagi
Posted 13-Mar-12 22:32pm

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 520
1 Andy Lanng 233
2 Sascha Lefèvre 210
3 OriginalGriff 188
4 Maciej Los 160
0 Sergey Alexandrovich Kryukov 9,713
1 OriginalGriff 8,475
2 Sascha Lefèvre 3,544
3 Maciej Los 3,106
4 Richard Deeming 2,370


Advertise | Privacy | Mobile
Web03 | 2.8.150520.1 | Last Updated 14 Mar 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100