Page 1 of 1

Creating a line chart which takes the first value as 100%

Posted: Fri Jul 07, 2006 12:43 pm
by 8119963
Hi!

Is there any function or possibility to tell TeeChart that it should take the first of its datasource values as 100%, and the rest of the values should be the percentage in comparison to the first one?
I think its called "Performance-Chart" in business...

Or is it better or easier to create a function in the database that returns the percentages?

Posted: Fri Jul 07, 2006 2:32 pm
by narcis
Hi Tony,

Performance charts are not directly supported but I guess they can be easily achieved. For example you can do something like this:

Code: Select all

    private void AddPercentValue(double percent)
    {
      double value = bar1.YValues[0] * (percent / 100);

      if (percent > 100) 
      {
        bar1.Add(value, Color.Red);
      }
      else
        if (percent < 100)
        {
          bar1.Add(value, Color.Yellow);
        }
        else
        {
          bar1.Add(value, Color.Green);
        }

    }

    private void Form1_Load(object sender, EventArgs e)
    {
      //Set initial value
      bar1.Add(123, Color.Blue);

      //Add values as the percent of the original
      AddPercentValue(55);
      AddPercentValue(73);
      AddPercentValue(112);
      AddPercentValue(105);
      AddPercentValue(23);
      AddPercentValue(87);
      AddPercentValue(100);
      AddPercentValue(75);
      AddPercentValue(85);
    }
If that's not what you are trying to achieve don't hesitate to ask here and if possible give us more information on what would you exactly like to get.