Infragistics Home

Infragistics Forums

Infragistics community online discussions.
Welcome to Infragistics Forums Sign in | FAQ
in Search

NullValues on a Time-scale line chart

Last post 06-30-2008 12:08 by [Infragistics] Max Rivlin. 3 replies.
Page 1 of 1 (4 items)
Sort Posts: Previous Next
  • 04-29-2008 9:11

    • Bernd_T
    • Not Ranked
    • Joined on 04-29-2008
    • Points 20

    NullValues on a Time-scale line chart

    Hi all

    I want to create a simple time-scaled linechart.
    Therefore I have a row-based DataTable, first column is called "Timestamp" and has the type DateTime.
    The other columns are numeric of type int and can be NULL.

    That's how I bind the data:

    =============================================== 

        protected void Page_Load(object sender, EventArgs e)
        {
            this.chartCtrl.LineChart.TreatDateTimeAsString = false;
            this.chartCtrl.Data.SwapRowsAndColumns = true;
            this.chartCtrl.Axis.X.Labels.ItemFormatString = "<ITEM_LABEL:dd-hh>";
            this.chartCtrl.Axis.X.TimeAxisStyle.TimeAxisStyle = Infragistics.UltraChart.Shared.Styles.RulerGenre.Discrete;
            this.chartCtrl.LineChart.NullHandling = Infragistics.UltraChart.Shared.Styles.NullHandling.InterpolateSimple;

            this.chartCtrl.DataSource = CreateTimebasedDataSource();
            this.chartCtrl.DataBind();
        }

        private DataTable CreateTimebasedDataSource()
        {
            DataTable mydata = new DataTable();
            Random rnd = new Random();
            DateTime stepTime = DateTime.Now;

            mydata.Columns.Add( "Timestamp", typeof( DateTime ) );
            mydata.Columns.Add( "Series 1", typeof( int ) );

            for ( int i = 0; i < 10; ++i )
            {
              // randomly set timestamp intervall
              stepTime = stepTime.AddHours( 1 + rnd.Next( 5 ) );

              // randomly create a real numeric value or a NULL - entry
              object val1 = ( i % 2 == 0 ) ? ( object ) rnd.Next( 100 ) : null;

              mydata.Rows.Add( new Object[ { stepTime, val1 } );
            }               

            return mydata;
        }

    ================================================== 

    Everything works fine as long as I don't have NULL values in the numeric columns, but as soon as I have a numeric value, just the labels on the X-Axis are displayed but not the according curve.

    Can please somebody help me ?

    Thanks in advance & greetings
      Bernd

     

    • Post Points: 20
  • 05-01-2008 11:48 In reply to

    Re: NullValues on a Time-scale line chart

    When using a discrete TimeAxisStyle, the tickmarks and labels are generated based on your random timestamp. Setting nullhandling to InterpolateSimple, takes the average of the next and previous points and puts it in the middle of the two, so it will not line up with the gridline. Try using InterpolateCustom instead and handle InterpolateValues event. You'll get more control where the data point is placed.

    • Post Points: 20
  • 06-22-2008 18:02 In reply to

    Re: NullValues on a Time-scale line chart

    Is there any example to show how we can use the InterpolateCustom for the Line Chart?

    • Post Points: 20
  • 06-30-2008 12:08 In reply to

    Re: NullValues on a Time-scale line chart

    While there are no existing code examples on this topic, here's how it works:
    You bind your line chart to some data that has null values. If you set LineChart.NullHandling property to InterpolateCustom, the chart's InterpolateValues event will fire. In this event you get the array of null value indices and the array of values themselves. Simply replace the null values in e.Values with any values you want.

    • Post Points: 5
Page 1 of 1 (4 items)
Powered by Community Server (Commercial Edition), by Telligent Systems