This is a migrated thread and some comments may be shown as answers.

Please help me how to display ChartView scroll bar(UI Wnforms)

3 Answers 84 Views
ChartView
This is a migrated thread and some comments may be shown as answers.
HEE KYUNG
Top achievements
Rank 1
HEE KYUNG asked on 25 Mar 2014, 08:47 AM
Hello.!

I am a user who uses your Telerik library.
Currently, I have been programming CharView on Winfom.
In case of the program that I develop, Whenever I click a button, it draws a chart then BindingList’s data is increasing continuously.
What I want to do is that let the Scroll bar be displayed when the number of data is over 20.
However, my program does not display Scroll bar when that happens.
My code is the following.

public partial class Form1 : Form
    {
        private BindingList<SampleData> _collectiontempsite1;
 
        public Form1()
        {
            InitializeComponent();
        }
 
        private void Form1_Load(object sender, EventArgs e)
        {
            _collectiontempsite1 = new BindingList<SampleData>();           
 
            radChartView1.ShowTitle = true;
            radChartView1.Title = "Sample";
 
            ClearChart();
            DrawChart();
        }
 
        private void ClearChart()
        {
            radChartView1.Series.Clear();
            radChartView1.Axes.Clear();
        }
 
        private void DrawChart()
        {
            CategoricalAxis horizontalAxis = new CategoricalAxis();
            horizontalAxis.PlotMode = AxisPlotMode.OnTicksPadded;
            //      horizontalAxis.LabelFitMode = AxisLabelFitMode.Rotate;
            //      horizontalAxis.LabelRotationAngle = 270;
            horizontalAxis.LabelInterval = 10;          
 
            LinearAxis verticalAxis = new LinearAxis();
            verticalAxis.AxisType = AxisType.Second;          
            verticalAxis.LabelInterval = 2;          
 
            CartesianSeries series1 = null;
            series1 = new LineSeries();
            series1.LegendTitle = "site1";
            series1.PointSize = new SizeF(5, 5);
            series1.HorizontalAxis = horizontalAxis;
            series1.VerticalAxis = verticalAxis;
            series1.BorderWidth = 2;
            series1.CategoryMember = "Time";
            series1.ValueMember = "Temp";
            series1.DataSource = _collectiontempsite1;           
            //series1.ShowLabels = true;
            series1.CombineMode = ChartSeriesCombineMode.None;
 
            radChartView1.Series.Add(series1);
            radChartView1.Area.View.Palette = KnownPalette.Summer;
 
            radChartView1.VerticalScroll.Enabled = true;
            radChartView1.VerticalScroll.Visible = true;
            radChartView1.HorizontalScroll.Enabled = true;
            radChartView1.HorizontalScroll.Visible = true;     
        }
 
        private void button1_Click(object sender, EventArgs e)
        {
            Random r = new Random(DateTime.Now.Millisecond);
 
            string strCurrentTime = DateTime.Now.ToString("hh:mm:ss:ffff");
            double dTemp = Convert.ToDouble(r.Next(70, 120));
            _collectiontempsite1.Add(new SampleData(strCurrentTime, dTemp));
        }
    }



Please respond to what I concern. Thank you.

3 Answers, 1 is accepted

Sort by
0
Dimitar
Telerik team
answered on 25 Mar 2014, 12:02 PM
Hi Hee,

Thank you for writing.

You can use the built in Scroll and Zoom functionality in order to achieve the desired effect. For example you can zoom and then scroll the chart when a new data point is added. This currently is not supported directly, but can be done by using reflection:
private void button1_Click(object sender, EventArgs e)
{
    Random r = new Random(DateTime.Now.Millisecond);
 
    string strCurrentTime = DateTime.Now.ToString("hh:mm:ss:ffff");
    double dTemp = Convert.ToDouble(r.Next(700, 1200));
    _collectiontempsite1.Add(new SampleData(strCurrentTime, dTemp));
 
     
 
    if (_collectiontempsite1.Count > 10)
    {
        IChartView view = this.radChartView1.View;
 
        radChartView1.Zoom((double)_collectiontempsite1.Count / 10d, 1);        
 
        MethodInfo method = typeof(ChartPanZoomController).GetMethod("OnPanGesture", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic);
        ConstructorInfo ci = typeof(PanGestureEventArgs).GetConstructor(BindingFlags.Instance | BindingFlags.NonPublic, null, new Type[] { typeof(Size), typeof(Size), typeof(GESTUREINFO), typeof(RadControl) }, null);
        PanGestureEventArgs args = ci.Invoke(new object[] { new Size(int.MinValue, 0), new Size(1, 0), default(GESTUREINFO), this.radChartView1 }) as PanGestureEventArgs;
        method.Invoke(panZoomController, new object[] { args });
    }          
}

Please note that there is no way to show a scrollbar, however the user can scroll with the mouse (Left Mouse Button Down+Move).

Please let me know if there is something else I can help you with. 

Regards,
Dimitar
Telerik
 

Build cross-platform mobile apps using Visual Studio and .NET. Register for the online webinar on 03/27/2014, 11:00AM US ET.. Seats are limited.

 
0
HEE KYUNG
Top achievements
Rank 1
answered on 25 Mar 2014, 11:46 PM
Hello, 
 I really appreciate it for your help.


0
Dimitar
Telerik team
answered on 26 Mar 2014, 02:44 PM
Hello Hee,

Thank you for writing back.

I am glad I could be of help. Let us know if you have any other questions.

Regards,
Dimitar
Telerik
 

Build cross-platform mobile apps using Visual Studio and .NET. Register for the online webinar on 03/27/2014, 11:00AM US ET.. Seats are limited.

 
Tags
ChartView
Asked by
HEE KYUNG
Top achievements
Rank 1
Answers by
Dimitar
Telerik team
HEE KYUNG
Top achievements
Rank 1
Share this question
or