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
395
Data offset between first and second layer of composite chart
posted

Hi,

I created a composite chart composed with a column chart and a scatter chart (dotted line).

At first glance, it seems to work ok (see "date offset.jpg"). The problem I have is that there's an offset between the dotted line and the column chart.

For example, if you look at the data that serves to generated the chart (see "chart data.jpg"), the dotted line value at the date "2014-03-02" should be "750" but it is "1350".

The problem I think I have is that the width between two points is not the same as the width of a column, so the offset is created from that. What properties can I adjust to solve this?

As you will see in my code, I had to create an X2 axis to be able to display the dotted line and from what I read, I cannot use the same "string" datatatype on the other axis so I created a "SemaineCount" (WeekCount in English) to use as the X value. Maybe the source of the problem resides there...

Thanks for your help,

Olivier

PS: I added an excel spreadsheet for you to have a reference between what you see on the chart and what the values are supposed to be.

Ultrachart problem.rar
  • 53790
    posted

    Hello Olivier,

    Maybe one possible approach to solve this task could be if you are using FillSceneGraph event and Offset method of your Primitives. For example:

     private void ultraChart1_FillSceneGraph(object sender, Infragistics.UltraChart.Shared.Events.FillSceneGraphEventArgs e)
            {
                List<Primitive> list = new List<Primitive>();
                List<Box> listBox = new List<Box>();
                foreach (Primitive item in e.SceneGraph)
                {
                    Box pl = item as Box;
                    if (pl != null && pl.Series != null)
                    {
                        pl.rect = new Rectangle(pl.rect.X +20, pl.rect.Y, pl.rect.Width - 20, pl.rect.Height);
                        listBox.Add(pl);
                    }

                    if (pl != null && pl.Series != null && ((NumericDataPoint)pl.DataPoint).Value != null)
                    {
                        Text txt = new Text();
                        txt.SetTextString(((NumericDataPoint)pl.DataPoint).Value.ToString());
                        txt.bounds.Location = new Point(pl.rect.X + (pl.rect.Width / 2 - 5), pl.rect.Y + (pl.rect.Height / 2));
                        list.Add(txt);
                    }

                    Polyline line = item as Polyline;
                    if (line != null)
                    {
                        int k=0;
                        foreach (DataPoint pp in line.points)
                        {

                            pp.point.X = listBox[k].rect.X + (listBox[k].rect.Width / 2 );
                            k++;
                        }
                    }
                }
            }

    Let me know if  you have any questions.