how to wrap series labels
how to wrap series labels
hi
I have a stacked bar cahrt. I want that labels should be wrapped when ever there is space between them.That is suppose label is "JJ HH NN". so it should show as
JJ
HH
NN
How to do this?.. thanks.
I have a stacked bar cahrt. I want that labels should be wrapped when ever there is space between them.That is suppose label is "JJ HH NN". so it should show as
JJ
HH
NN
How to do this?.. thanks.
Re: how to wrap series labels
Hello shikha,
I made a simple project, that I think helps, for put labels series wrap. Please see next code and check works correctly in your applicaiton.
I hope will helps.
Thanks,
I made a simple project, that I think helps, for put labels series wrap. Please see next code and check works correctly in your applicaiton.
Code: Select all
public Form1()
{
InitializeComponent();
InitializeChart();
}
private void InitializeChart()
{
tChart1.Aspect.View3D = false;
Steema.TeeChart.Styles.Bar bar = new Steema.TeeChart.Styles.Bar(tChart1.Chart);
Steema.TeeChart.Styles.Bar bar1 = new Steema.TeeChart.Styles.Bar(tChart1.Chart);
Steema.TeeChart.Styles.Bar bar2 = new Steema.TeeChart.Styles.Bar(tChart1.Chart);
tChart1.Panel.MarginBottom = 12;
bar.FillSampleValues();
bar1.FillSampleValues();
bar2.FillSampleValues();
bar.Marks.Visible = false;
bar1.Marks.Visible = false;
bar2.Marks.Visible = false;
bar.MultiBar = Steema.TeeChart.Styles.MultiBars.Stacked;
for (int i = 0; i < bar.Count; i++)
{
bar.Labels[i] = "JJ" + "\n"+"HH" + "\n"+"NN" + "\n";
}
}
Thanks,
Best Regards,
Sandra Pazos / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |
Re: how to wrap series labels
thanks but this looks hardcoded, can u make it dynamic as the data will keep on changing and i have many labels?
Re: how to wrap series labels
Hi shikha,
You could use OnGetAxisLabels to retrieve each label text and modify it as you wish. For example you could change the 'space' for '\n':
You could use OnGetAxisLabels to retrieve each label text and modify it as you wish. For example you could change the 'space' for '\n':
Code: Select all
public Form1()
{
InitializeComponent();
InitializeChart();
}
private void InitializeChart()
{
tChart1.Aspect.View3D = false;
Steema.TeeChart.Styles.Bar bar1 = new Steema.TeeChart.Styles.Bar(tChart1.Chart);
Steema.TeeChart.Styles.Bar bar2 = new Steema.TeeChart.Styles.Bar(tChart1.Chart);
Steema.TeeChart.Styles.Bar bar3 = new Steema.TeeChart.Styles.Bar(tChart1.Chart);
tChart1.Panel.MarginBottom = 12;
bar1.FillSampleValues();
bar2.FillSampleValues();
bar3.FillSampleValues();
bar1.Marks.Visible = false;
bar2.Marks.Visible = false;
bar3.Marks.Visible = false;
bar1.MultiBar = Steema.TeeChart.Styles.MultiBars.Stacked;
for (int i = 0; i < bar1.Count; i++)
{
bar1.Labels[i] = "JJ HH NN";
}
tChart1.Axes.Bottom.GetAxisDrawLabel += new GetAxisDrawLabelEventHandler(Bottom_GetAxisDrawLabel);
}
void Bottom_GetAxisDrawLabel(object sender, GetAxisDrawLabelEventArgs e)
{
e.Text = e.Text.Replace(' ', '\n');
}
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
Re: how to wrap series labels
Should this little line work too?
Code: Select all
tcChart.Axes.Bottom.Labels.MultiLine = true;
Re: how to wrap series labels
Hi AIS,
That's for being used with datetimes, as the help says.
That's for being used with datetimes, as the help says.
For example:Steema.TeeChart.AxisLabels.MultiLine Property help wrote:Activate Multiline Axis Labels. TeeChart will automaticall break DateTime Labels on occurence of a space " ". Use '\n' in other label types to break a line or use the SplitInLines method in the OnGetAxisLabel event.
Code: Select all
public Form1()
{
InitializeComponent();
InitializeChart();
}
private void InitializeChart()
{
tChart1.Aspect.View3D = false;
Steema.TeeChart.Styles.Bar bar1 = new Steema.TeeChart.Styles.Bar(tChart1.Chart);
Steema.TeeChart.Styles.Bar bar2 = new Steema.TeeChart.Styles.Bar(tChart1.Chart);
Steema.TeeChart.Styles.Bar bar3 = new Steema.TeeChart.Styles.Bar(tChart1.Chart);
tChart1.Panel.MarginBottom = 12;
bar1.FillSampleValues();
bar2.FillSampleValues();
bar3.FillSampleValues();
bar1.Marks.Visible = false;
bar2.Marks.Visible = false;
bar3.Marks.Visible = false;
bar1.MultiBar = Steema.TeeChart.Styles.MultiBars.Stacked;
bar1.XValues.DateTime = true;
tChart1.Axes.Bottom.Labels.DateTimeFormat = "dd/MM/yyyy hh:mm:ss";
tChart1.Axes.Bottom.Labels.MultiLine = true;
}
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |
Re: how to wrap series labels
This code
e.LabelText = e.LabelText.Replace(" ", "\n")
is not working-
its giving \n within text.
That is if label is xx yy zz then using his gives xx\nyy\nzz
plesae let me know what to do.
e.LabelText = e.LabelText.Replace(" ", "\n")
is not working-
its giving \n within text.
That is if label is xx yy zz then using his gives xx\nyy\nzz
plesae let me know what to do.
Re: how to wrap series labels
doing by using ControlChars.NewLine or vbCrLf ( i am using vb.net, so that was the reason probably \n did not work). But now i am facing another issue. I am using data table tool and doing this is inserting empty rows in that . So for example if in my label i am giving one carriage return that in data table also its inserting one empty row , if i m giving twoe carriage return that in data table also its inserting two empty row like this-
bar1 66 88
bar2 88 99
bar1 66 88
bar2 88 99
Re: how to wrap series labels
Hello shikha,
Using last version 4 and last version 3 of TeeChart.Net, chart appears next image using this code:
Please, could you say if this is your problem?
If it isn't your problem, please you could send us a simple project, because we can reproduce your problem here.
Thanks,
Using last version 4 and last version 3 of TeeChart.Net, chart appears next image using this code:
Code: Select all
Private Sub InitializeChart()
TChart1.Aspect.View3D = False
Dim datatool1 As Steema.TeeChart.Tools.DataTableTool = New Steema.TeeChart.Tools.DataTableTool(TChart1.Chart)
Dim bar1 As Steema.TeeChart.Styles.Bar = New Steema.TeeChart.Styles.Bar(TChart1.Chart)
Dim bar2 As Steema.TeeChart.Styles.Bar = New Steema.TeeChart.Styles.Bar(TChart1.Chart)
TChart1.Header.Visible = False
bar1.FillSampleValues()
bar2.FillSampleValues()
bar1.Marks.Visible = False
bar2.Marks.Visible = False
bar1.MultiBar = Steema.TeeChart.Styles.MultiBars.Stacked
Dim i As Integer
For i = 0 To bar1.Count - 1
bar1.Labels(i) = "JJ HH"
Next
datatool1.RowPen.Visible = True
datatool1.RowPen.Color = Color.Black
datatool1.ColumnPen.Visible = True
datatool1.ColumnPen.Color = Color.Black
AddHandler TChart1.Axes.Bottom.GetAxisDrawLabel, AddressOf Me.Bottom_GetAxisDrawLabel
End Sub
Private Sub Bottom_GetAxisDrawLabel(ByVal sender As Object, ByVal e As Steema.TeeChart.GetAxisDrawLabelEventArgs)
e.Text = e.Text.Replace(" ", vbLf)
End Sub
If it isn't your problem, please you could send us a simple project, because we can reproduce your problem here.
Thanks,
Best Regards,
Sandra Pazos / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |
Re: how to wrap series labels
EXACTLY.. this is the issue i am facing!!!
Re: how to wrap series labels
please let me know how to solve this( which you have reproduced at your end). many thanks.
Re: how to wrap series labels
Hi
Any luck? is there any solution to this?
Any luck? is there any solution to this?
Re: how to wrap series labels
Hi shikha,
You could change the series' labels when you want, something like following:
If you are looking for prioritary support you you may be interested in knowing of our Pro-Support service:
http://www.steema.com/licensing/support
You could change the series' labels when you want, something like following:
Code: Select all
private void button1_Click(object sender, EventArgs e)
{
WrapLabels(bar1);
}
private void WrapLabels(Steema.TeeChart.Styles.Bar bar)
{
int maxHeight = 0;
int tmpHeight;
for (int i = 0; i < bar1.Count; i++)
{
bar1.Labels[i] = bar1.Labels[i].Replace(" ", "\n");
tmpHeight = (int)tChart1.Graphics3D.TextHeight(bar1.Labels[i]);
if (tmpHeight > maxHeight) maxHeight = tmpHeight;
}
datatool1.AutoPosition = false;
tChart1.Panel.MarginUnits = Steema.TeeChart.PanelMarginUnits.Pixels;
tChart1.Panel.MarginBottom = maxHeight + tChart1.Series.Count * (int)tChart1.Graphics3D.TextHeight("S");
tChart1.Panel.MarginLeft = 15;
tChart1.Panel.MarginTop = 10;
datatool1.Top = tChart1.Axes.Bottom.Position + (maxHeight/3);
}
http://www.steema.com/licensing/support
Best Regards,
Yeray Alonso Development & Support Steema Software Av. Montilivi 33, 17003 Girona, Catalonia (SP) | |
Please read our Bug Fixing Policy |