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
430
Mimic Excel Graph
posted

Hello all,

I am trying to mimic the Excel graph shown so that the red lines between the 2nd and 3rd lines to show the spread.  Is there anyway to do this in UltraChart?  Also, I am trying to get the week to show on the x-axis.  I am pulling the week in from a DB2 database, and the dates are returning as required.

Thanks for all the help in advance!

Parents
No Data
Reply
  • 18495
    posted

    This is only possible with the help of FillSceneGraph event. Here I’m using a polygon with a hatch. If you need to add each vertical line manually, you can always do that, too, since you already have the points. I’m not really sure what you mean by displaying the weeks. Does that mean week numbers? I don’t think there’s a string format that does that, and if so, you’ll need to implement IRenderLabel , find the week number from the date and insert is as a string into the label.

    private void Form1_Load(object sender, EventArgs e)
    {
        ultraChart1.Data.DataSource = new int[,]
        {
            {1,2,1,3,2,4,3,5,4,5},
            {4,5,4,7,4,7,6,7,9,8}
        };
    }
    
    private void ultraChart1_FillSceneGraph(object sender, FillSceneGraphEventArgs e)
    {
        List lines = new List();
        List points = new List();
    
        foreach (var p in e.SceneGraph)
        {
            if (p is Polyline) lines.Add(p as Polyline);
        }
    
        if (lines.Count < 2) return;
    
        foreach (var point in lines[0].points)
        {
            points.Add(point.point);
        }
    
        foreach (var point in lines[1].points.Reverse())
        {
            points.Add(point.point);
        }
    
        Polygon area = new Polygon(points.ToArray());
        PaintElement pe = new PaintElement();
        pe.ElementType = PaintElementType.Hatch;
        pe.Hatch = FillHatchStyle.Vertical;
        pe.Fill = Color.Red;
        pe.FillStopColor = Color.Transparent;
        area.PE = pe;
    
        e.SceneGraph.Add(area);
    }
Children