Adding a scroll bar to MS Chart control C#

please understand that I know there are other threads concerning this issue, but my needs are different.

Basically before I seen people saying to implement a scroll bar with MSChart they use the

.Size = ...

or

.View = ...

But, this make a scroll bar automatically apprear, and this scroll bar contains a button that when clicked causes the bar to vanish, making the chart show all data, and no way of bringing back the scroll bar to the chart without restarting the app.

So I ask, please, Is there a way to incorportate a horizontal scroll bar on the X-axis of my Chart? I am needing on so that I can view my chart data on blocks of 100 second blocks.

i.e. 0 - 100, then click sroll bar will bring me to 100 - 200 block.

Thank you in advance guys!!!!! im coding in C# also

Here's an example of what you need: (to try it, just create a form, add a mschart and call the following method)

private void FillChart()
{
    int blockSize = 100;

    // generates random data (i.e. 30 * blockSize random numbers)
    Random rand = new Random();
    var valuesArray = Enumerable.Range(0, blockSize * 30).Select(x => rand.Next(1, 10)).ToArray();

    // clear the chart
    chart1.Series.Clear();

    // fill the chart
    var series = chart1.Series.Add("My Series");
    series.ChartType = SeriesChartType.Line;
    series.XValueType = ChartValueType.Int32;
    for (int i = 0; i < valuesArray.Length; i++)
        series.Points.AddXY(i, valuesArray[i]);
    var chartArea = chart1.ChartAreas[series.ChartArea];

    // set view range to [0,max]
    chartArea.AxisX.Minimum = 0;
    chartArea.AxisX.Maximum = valuesArray.Length;

    // enable autoscroll
    chartArea.CursorX.AutoScroll = true;

    // let's zoom to [0,blockSize] (e.g. [0,100])
    chartArea.AxisX.ScaleView.Zoomable = true;
    chartArea.AxisX.ScaleView.SizeType = DateTimeIntervalType.Number;
    int position = 0;
    int size = blockSize;
    chartArea.AxisX.ScaleView.Zoom(position, size);

    // disable zoom-reset button (only scrollbar's arrows are available)
    chartArea.AxisX.ScrollBar.ButtonStyle = ScrollBarButtonStyles.SmallScroll;

    // set scrollbar small change to blockSize (e.g. 100)
    chartArea.AxisX.ScaleView.SmallScrollSize = blockSize;
}

Snapshot:

Add scroll bar on Bar chart created by System.Windows.Forms , Chart Controls for . The problem is when bars increases, chart area goes shrink. I don't want it to shrieked. I want to add scroll bar on it. Friday� Add your chart to a Panel. Set the AutoScroll property of the panel to true with panelName.AutoScroll=true; Size the chart properly in the panel. You can now use the panel's scrollbar as if it were the chart's! If data gets added continuously(e.g. with a timer or so), add this to the timer's tick event:

I would do it like this:

    if (series1.Points.Count > 2 && chartArea1.AxisX.Maximum - chartArea1.AxisX.Minimum > chartArea1.AxisX.ScaleView.Size)
{
   chartArea1.AxisX.ScrollBar.Enabled = true;
}
else
{
   chartArea1.AxisX.ScrollBar.Enabled = false;
}

So when you added points more than your scaleview - scrollbar is appear

AxisScrollBar Class (System.Windows.Forms.DataVisualization , Add Scrollbar to the X-Axis and Y-Axis. The following steps show how to add Scrollbars to the X and Y axis of the Chart. Using the Properties Window: 1. In the � I want to add text(say, annotations) in MS chart(winforms) like (10, 20) , (30, 40) where I already have a scroll bar. I can able to draw strings(graphics.drawstring

I worked out my own way for that. Hope it helps you:

  1. Add your chart to a Panel.

  2. Set the AutoScroll property of the panel to true with panelName.AutoScroll=true;

  3. Size the chart properly in the panel.

  4. You can now use the panel's scrollbar as if it were the chart's!

  5. If data gets added continuously(e.g. with a timer or so), add this to the timer's tick event:

    chartName.Size = new Size(width++, height++); where int width = chartName.Width; and int height = chartName.Height;

Add Scrollbar to the X-Axis and Y-Axis, Fill; this.Controls.AddRange(new Control[] { chart }); // Create a Bar series and add points to it. Series series1 = new Series("Bar", ViewType. Private Sub InitializeMyScrollBar () ' Create and initialize a VScrollBar. Dim vScrollBar1 As New VScrollBar () ' Dock the scroll bar to the right side of the form. vScrollBar1.Dock = DockStyle.Right ' Add the scroll bar to the form. Controls.Add (vScrollBar1) End Sub.

How to: Individually Adjust Axes Scrolling (Runtime Sample , The Chart control allows you to enable the capability to zoom a chart's C#; VB. NET. XYDiagram xyDiagram = (XYDiagram)chartControl. Users can utilize a mouse, keyboard, scroll bars and flick gestures on Add(Keys. Chart control can be found in Toolbox(.NET Framework 4.0 or newer). Older versions will not have the Chart control available. To add a chart control to your application, In design view, open the Toolbox. From the Data category, drag a Chart control to the design area.

Zoom and Scroll in 2D XY-Charts | WinForms Controls, Not sure if my suggestion will help you or not but check this for a try- You can embed the chart control in a div with fixed height (and width,� Here Anand Krish provided a short tutorial with example, how to create Chart Control in Windows Forms applicaton. In Windows Forms application, there is already predefined control is availabe ( Chart ). Using the Chart Control we can draw Bar chart, pie Chart, line chart and Etc.

How do I add a horizontal scroll bar in ASP.NET chart control?, You can do one thing take panel and inside that panel put your chart control. Now you can check property of panel "scroll" and set as you� To fix the position of scrollbars, the plotting area position of a chart area must not be set to Auto. To explicitly set the plotting area position, use the InnerPlotPosition property. To display scrollbars when a chart is first displayed, use the AxisScaleView class properties and methods so that a view is initially displayed to end users.

Comments
  • @digEmAll, the snapshot link is broken.
  • @Devendra: It's not a link but there's an image below... maybe your browser didn't load the image... ?
  • @digEmAll, the image is not visible. I tried to check the link (by editing the answer), but even this is invalid.
  • @digEmAll, the snapshot is visible.
  • @digEmAll, the image might have been blocked by the firewall at my office. :)