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
670
How to override TreeMapChart rectangle size?
posted

Suppose I have this data to chart in a TreeMap:

DataTable dt = new DataTable("MyTable");
dt.Columns.Add("Severity", typeof(string));
dt.Columns.Add("Name", typeof(string));
dt.Columns.Add("Count", typeof(double));

var dr = dt.NewRow();
dt.Rows.Add(new object[] { "information", "backup completed successfuly", 20000 });
dt.Rows.Add(new object[] { "warning", "low disk space", 4 });
dt.Rows.Add(new object[] { "warning", "temperature is rising", 2 });
dt.Rows.Add(new object[] { "warning", "cpu level is high", 1 });
dt.Rows.Add(new object[] { "critical", "database has 10MB freespace left", 4 });
dt.Rows.Add(new object[] { "critical", "IIS is having too many errors", 4 });
dt.Rows.Add(new object[] { "security", "SQL Injection attack", 4 });
dt.Rows.Add(new object[] { "security", "Password attack", 2 });

If I run this code I will only see "backup completed..." rectangle since the treemap calculates the rectangle size linearly. However, if I add the following code before setting the chart's datasource, it looks fine but this time tooltips displays logarithmic values!

foreach (DataRow dr1 in dt.Rows)
{  
     dr1["Count"] = Math.Log10((double)dr1["Count"]);
}

My question; is there a way to override how TreeMapChart gets the value? or any workarounds?

  • 53790
    posted

    Hello Murat,

    Maybe one custom solution could be, if you implement FillSceneGraph event. By this way you could override your Box primitives that represent rectangles in the treemap chart.

    For example you could try the code below. Please note that you should extend IF condition according your requirement :

      private void ultraChart1_FillSceneGraph(object sender, FillSceneGraphEventArgs e)

            {

                foreach (Primitive pr in e.SceneGraph)

                {

                    if (pr is Box && pr.Series != null && pr.Series.Key == "series1")

                    {

                        ((Infragistics.UltraChart.Core.Primitives.Box)(pr)).rect.Width = 80;

                    }

                }

            }

     Let me know if you have any questions.