Page 1 of 1

Unique Bargraph

Posted: Fri Mar 27, 2015 1:27 pm
by 15670607
Hi,

Would like to know how to set the width of a Mark, so that it represents what I've indicated in the "want-to-have.png" image. Also attached is my current code and a screen shot of what I've currently done. In my third bar or "Column" the Mark text doesn't wrap and goes over the text in column 2 (bar 2).

If there's another way of doing what I want to achieve, please feel free to comment.

Platform is Silverlight, Net 4.0

Thanks

Re: Unique Bargraph

Posted: Mon Mar 30, 2015 8:47 am
by Christopher
cjherasmus wrote:If there's another way of doing what I want to achieve, please feel free to comment.
One suggestion would be the use of Annotation tools, e.g.

Code: Select all

    Steema.TeeChart.Silverlight.Styles.Bar series = new Bar();
    Annotation annotation1, annotation2, annotation3;

    private void InitializeChart()
    {

      tChart1.Aspect.View3D = false;
      tChart1.Panel.Gradient.Visible = false;
      tChart1.Walls.Back.Gradient.Visible = false;
      tChart1.Panel.Color = Colors.White;
      tChart1.Walls.Back.Color = Colors.White;
      tChart1.Axes.Bottom.SetMinMax(0, 1);

      tChart1.Series.Add(series);


      series.Marks.Visible = false;
      series.Add(-20, Colors.Orange);
      series.Add(-10, Colors.Blue);
      series.Add(-30, Colors.Green);

      annotation1 = new Annotation(tChart1.Chart);
      annotation2 = new Annotation(tChart1.Chart);
      annotation3 = new Annotation(tChart1.Chart);

      annotation1.Shape.CustomPosition = true;
      annotation2.Shape.CustomPosition = true;
      annotation3.Shape.CustomPosition = true;

      annotation1.Shape.Shadow.Visible = false;
      annotation2.Shape.Shadow.Visible = false;
      annotation3.Shape.Shadow.Visible = false;

      series.MultiBar = MultiBars.SelfStack;

      tChart1.AfterDraw +=tChart1_AfterDraw;

      tChart1.BeforeDrawSeries += tChart1_BeforeDrawSeries;

    }

    void tChart1_BeforeDrawSeries(object sender, Graphics3D g)
    {
      annotation1.Top = series.GetVertAxis.IStartPos;
      annotation1.Left = tChart1.Axes.Bottom.CalcXPosValue(1);
      annotation1.Height = series.CalcYPos(0) - annotation1.Top;
      annotation1.Width = tChart1.Axes.Bottom.CalcXPosValue(2) - annotation1.Left;
      annotation1.Text = "Here comes text, here come" + Utils.NewLine + "s text, here comes";

      annotation2.Top = series.CalcYPos(0);
      annotation2.Left = tChart1.Axes.Bottom.CalcXPosValue(1);
      annotation2.Height = series.CalcYPos(1) - annotation2.Top;
      annotation2.Width = tChart1.Axes.Bottom.CalcXPosValue(2) - annotation2.Left;
      annotation2.Text = "Here comes text, here come" + Utils.NewLine + "s text, here comes";

      annotation3.Top = series.CalcYPos(1);
      annotation3.Left = tChart1.Axes.Bottom.CalcXPosValue(1);
      annotation3.Height = series.CalcYPos(2) - annotation3.Top;
      annotation3.Width = tChart1.Axes.Bottom.CalcXPosValue(2) - annotation3.Left;
      annotation3.Text = "Here comes text, here come" + Utils.NewLine + "s text, here comes";
    }