Click here to Skip to main content
16,021,430 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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

C#
//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

C#
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

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900