Home Forums WinForms controls Xceed Chart for WinForms Data Pan tool question

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #18831 |

    I have a fairly simple chart with a single bar series. The series can have a large number of points, so I thought data panning would be a good thing to provide. But I cannot get it to work. I have done the following:

    1. Added a DataPan tool to the Interactivity collection of the chart control
    I left all properties at default values.
    2. Enabled paging on the X-axis. I set the page mode to FixedPageCount mode, and set the page count to 5. I expected this to divide up the full extent of the x-axis into 5 pages. The X axis scale mode I initially left in Dimension, but I have also tried Numeric.

    Nothing happens when I drag the mouse (with the right buton) over the chart. The cursor does not change.

    What else do I need to do to enable this? I have looked through the documentation but it doesn’t help.

    Imported from legacy forums. Posted by Steve (had 2473 views)

    Xceed Support
    Member
    Post count: 5658

    We have a good sample regarding this issue in our Chart Explorer ( Start Menu -> All Programs -> Xceed Components -> Our components in action! -> Xceed Chart Explorer for .NET ), then go to All Examples -> Interactivity -> Data Panning.

    You can look at the code by clicking on the “C# Code” tab (you will find the complete source code of the explorer under -> C:\Program Files\Xceed Components\Xceed Chart for .NET and ASP.NET 4.1\Samples, or C:\Xceed Component Samples\Xceed Chart for .NET 4.1\Samples under Vista ).

    However, here is a snippet of code that should help you get started. You just need to drop a ChartControl on your Form and rename it to “m_ChartControl”.

    <code>
    public Form1()
    {
    InitializeComponent();
    }

    private Xceed.Chart.Core.Chart m_PanChart;
    private Xceed.Chart.Core.Chart m_PreviewChart;
    private BarSeries m_Bar;
    private DataPanTool m_DataPanTool;

    private void Form1_Load( object sender, EventArgs e )
    {
    m_ChartControl.Settings.RenderDevice = RenderDevice.GDI;
    m_ChartControl.Background.FillEffect.SetGradient( GradientStyle.Horizontal, GradientVariant.Variant1, Color.White, Color.DarkGreen );
    m_ChartControl.Legends[ 0 ].Mode = LegendMode.Disabled;

    // add a header label
    ChartLabel header = m_ChartControl.Labels.AddHeader( “Data Pan Tool” );
    header.TextProps.Backplane.Visible = false;
    header.TextProps.FillEffect.Color = Color.Cornsilk;
    header.TextProps.Shadow.Type = ShadowType.Solid;
    header.TextProps.Shadow.Color = Color.FromArgb( 64, 0, 64, 64 );
    header.TextProps.HorzAlign = HorzAlign.Left;
    header.TextProps.VertAlign = VertAlign.Top;
    header.HorizontalMargin = 2;
    header.VerticalMargin = 2;

    ConfigurePanChart();
    ConfigurePreviewChart();

    m_DataPanTool = new DataPanTool();
    m_ChartControl.InteractivityOperations.Add( m_DataPanTool );

    m_DataPanTool.EndDrag += new EventHandler( OnPanEndDrag );
    m_DataPanTool.DoDrag += new EventHandler( OnPanDoDrag );
    m_DataPanTool.Cancel += new EventHandler( OnCancel );

    m_PanChart.Axis( StandardAxis.PrimaryX ).Ruler.PageSize = 20;
    m_PanChart.Axis( StandardAxis.PrimaryY ).Ruler.PageSize = 20;
    m_DataPanTool.RepaintChartWhileDragging = true;

    }

    private void OnCancel( object sender, System.EventArgs e )
    {
    UpdatePreviewChart();
    m_ChartControl.Refresh();
    }

    private void OnPanEndDrag( object sender, System.EventArgs e )
    {
    UpdatePreviewChart();
    }

    private void OnPanDoDrag( object sender, System.EventArgs e )
    {
    if( m_DataPanTool.RepaintChartWhileDragging )
    {
    UpdatePreviewChart();
    }
    }

    private void UpdatePreviewChart()
    {
    Axis axis = m_PanChart.Axis( StandardAxis.PrimaryX );
    AxisStripe axisStripe = m_PreviewChart.Axis( StandardAxis.PrimaryX ).Stripes[ 0 ];

    axisStripe.From = axis.Ruler.CurrentPageBeginValue;
    axisStripe.To = axisStripe.From + axis.Ruler.PageSize;

    axis = m_PanChart.Axis( StandardAxis.PrimaryY );
    axisStripe = m_PreviewChart.Axis( StandardAxis.PrimaryY ).Stripes[ 0 ];

    axisStripe.From = axis.Ruler.CurrentPageBeginValue;
    axisStripe.To = axisStripe.From + axis.Ruler.PageSize;
    }

    private void ConfigurePanChart()
    {
    m_PanChart = m_ChartControl.Charts[ 0 ];
    m_PanChart.Axis( StandardAxis.Depth ).Visible = false;
    m_PanChart.Axis( StandardAxis.PrimaryY ).MajorGridLine.Pattern = LinePattern.Dot;
    m_PanChart.Axis( StandardAxis.PrimaryX ).MajorGridLine.Pattern = LinePattern.Dot;
    m_PanChart.Axis( StandardAxis.PrimaryX ).SetMajorShowAtWall( ChartWallType.Back, true );
    m_PanChart.Margins = new RectangleF( 10, 10, 80, 80 );
    m_PanChart.MarginMode = MarginMode.Stretch;

    m_Bar = ( BarSeries )m_PanChart.Series.Add( SeriesType.Bar );
    m_Bar.Name = “Bar Series”;
    m_Bar.DataLabels.Mode = DataLabelsMode.None;

    // add xy values
    Random random = new Random();

    for( int i = 0; i < 100; i++ )
    {
    m_Bar.Add( random.Next( 100 ), “Item” + i.ToString() );
    }

    // set the primary X axis in FixedPageSize mode
    Axis primaryX = m_PanChart.Axis( StandardAxis.PrimaryX );

    primaryX.ScaleMode = AxisScaleMode.Numeric;
    primaryX.Ruler.PagingMode = RulerPagingMode.FixedPageSize;
    primaryX.Ruler.PageSize = 10;
    primaryX.Ruler.CurrentPageBeginValue = 0;
    primaryX.Ruler.CurrentPageMode = RulerCurrentPageMode.BeginValue;

    // set the primary Y axis in FixedPageSize mode
    Axis primaryY = m_PanChart.Axis( StandardAxis.PrimaryY );

    primaryY.ScaleMode = AxisScaleMode.Numeric;
    primaryY.Ruler.PagingMode = RulerPagingMode.FixedPageSize;
    primaryY.Ruler.PageSize = 10;
    primaryY.Ruler.CurrentPageBeginValue = 0;
    primaryY.Ruler.CurrentPageMode = RulerCurrentPageMode.BeginValue;
    }

    private void ConfigurePreviewChart()
    {
    // confiure the preview chart
    m_PreviewChart = m_ChartControl.Charts.Add();
    m_PreviewChart.Axis( StandardAxis.Depth ).Visible = false;

    Axis primaryX = m_PreviewChart.Axis( StandardAxis.PrimaryX );

    primaryX.MajorGridLine.Pattern = LinePattern.Dot;
    primaryX.MajorGridLine.Pattern = LinePattern.Dot;
    primaryX.SetMajorShowAtWall( ChartWallType.Back, true );
    primaryX.ScaleMode = AxisScaleMode.Numeric;

    AxisStripe axisStripe = new AxisStripe();
    axisStripe.From = 0;
    axisStripe.To = 10;
    axisStripe.FillEffect.SetSolidColor( Color.FromArgb( 125, 255, 0, 0 ) );
    primaryX.Stripes.Add( axisStripe );
    primaryX.Visible = false;
    axisStripe.SetShowAtWall( ChartWallType.Back, true );

    Axis primaryY = m_PreviewChart.Axis( StandardAxis.PrimaryY );
    axisStripe = new AxisStripe();
    axisStripe.From = 0;
    axisStripe.To = 10;
    axisStripe.FillEffect.SetSolidColor( Color.FromArgb( 125, 0, 255, 0 ) );
    primaryY.Stripes.Add( axisStripe );
    primaryY.Visible = false;
    axisStripe.SetShowAtWall( ChartWallType.Back, true );

    BarSeries previewBarSeries = ( BarSeries )m_Bar.Clone();
    previewBarSeries.DataLabels.Mode = DataLabelsMode.None; SDJXCEED@

    Imported from legacy forums. Posted by CharlesB (had 3270 views)

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.