Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
70
Dont draw on 0 Value - Anyone?
posted

I am using a line chart.  Its working well.  However I am running into a bit of a challenge.  Perhaps someone can help?  See the image below.  See how the lines drop?  Thats because these weeks have no data yet.  I want the line to end when the 0s begin.  I know this cant be accross the board for all 0s or we would have bigger issues, but there has to be a way to control how the lines are drawn right? 

Parents
No Data
Reply
  • 2406
    Verified Answer
    posted

    Hi,

    You could use the ChartDrawItem event of the chart and remove the unnecessary points of the polyline which have 0s. The following example removes the last points from all polylines:

    protected void Page_Load(object sender, EventArgs e)
    {
        UltraChart1.ChartType = Infragistics.UltraChart.Shared.Styles.ChartType.LineChart;
        UltraChart1.ChartDrawItem += new Infragistics.UltraChart.Shared.Events.ChartDrawItemEventHandler(UltraChart1_ChartDrawItem);
        UltraChart1.DataSource = DemoTable.Table();
        UltraChart1.DataBind();
    }

    void UltraChart1_ChartDrawItem(object sender, Infragistics.UltraChart.Shared.Events.ChartDrawItemEventArgs e)
    {
        if (e.HasData)
        {           
            if (e.Primitive is Polyline)
            {
                Polyline pl = e.Primitive as Polyline;

                //check to see for the propriate polyline datavalue....
               
                DataPoint[] newPoints = new DataPoint[pl.points.Length - 1]; //create new points collection with less points
                for (int k = 0; k < newPoints.Length; k++)
                {
                    newPoints[k] = pl.points[k];
                }
                pl.points = newPoints; //change the points collection of the polyline
            }
        }
    }

Children