percentage mark on the Y- axis
-
- Newbie
- Posts: 58
- Joined: Thu Jul 05, 2012 12:00 am
percentage mark on the Y- axis
How do I add a percentage mark on the Y- axis
- Attachments
-
- graph.JPG (49.29 KiB) Viewed 7317 times
Re: percentage mark on the Y- axis
Hello mikethelad,
To achieve the percentage in the Y-axis, you only need change the style of the axes to get the style of Marks. You can do something as next lines of code:
I hope will helps.
Thanks,
To achieve the percentage in the Y-axis, you only need change the style of the axes to get the style of Marks. You can do something as next lines of code:
Code: Select all
Series1.Marks.Style = Steema.TeeChart.Styles.MarksStyles.Percent;
tChart1.Axes.Left.Labels.Style = AxisLabelStyle.Mark;
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 |
-
- Newbie
- Posts: 58
- Joined: Thu Jul 05, 2012 12:00 am
Re: percentage mark on the Y- axis
I only getting one % value if I do this, see example
- Attachments
-
- graph.JPG (23.66 KiB) Viewed 7277 times
Re: percentage mark on the Y- axis
Hello mikethelad,
In this case, the option is use GetAxisDrawLabel event of left axis as I do in next simple code where I have modified the text label adding a percentage:
Can you tell if previous code works as you want?
Thanks,
In this case, the option is use GetAxisDrawLabel event of left axis as I do in next simple code where I have modified the text label adding a percentage:
Code: Select all
public Form1()
{
InitializeComponent();
InitializeChart();
}
private void InitializeChart()
{
double MaxX, MinX;
tChart1.Aspect.View3D = false;
tChart1.Dock = DockStyle.Fill;
tChart1.Legend.Alignment = LegendAlignments.Bottom;
for (int i = 0; i < 2; i++)
{
new Steema.TeeChart.Styles.Line(tChart1.Chart);
tChart1[i].FillSampleValues(2);
tChart1[i].Marks.Visible = true;
tChart1[i].Marks.Style = Steema.TeeChart.Styles.MarksStyles.Percent;
}
tChart1.Axes.Left.GetAxisDrawLabel += new GetAxisDrawLabelEventHandler(Left_GetAxisDrawLabel);
tChart1.Axes.Bottom.MaximumOffset = 2;
tChart1.Axes.Bottom.MinimumOffset = 1;
tChart1.Axes.Left.MaximumOffset = 2;
tChart1.Axes.Left.MinimumOffset = 1;
}
void Left_GetAxisDrawLabel(object sender, GetAxisDrawLabelEventArgs e)
{
e.Text = e.Text + "%";
}
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 |
-
- Newbie
- Posts: 58
- Joined: Thu Jul 05, 2012 12:00 am
Re: percentage mark on the Y- axis
Nearly, the 100% is being choppied to 00%, I have tried increasing the offset to 15
WebChart1.Chart.Axes.Left.MinimumOffset = 15;
WebChart1.Chart.Axes.Left.MaximumOffset = 15;
WebChart1.Chart.Axes.Left.MinimumOffset = 15;
WebChart1.Chart.Axes.Left.MaximumOffset = 15;
- Attachments
-
- graph.JPG (38.49 KiB) Viewed 7265 times
Re: percentage mark on the Y- axis
Hello mikethelad,
I can try to reproduce your problem but it not occurs for me using last version of TeeChartFor.Net and next code:
Please see previous code and check if your problem occurs using it. If occurs, please can you tell us which version of TeeChart are you using?
On the other hand, seeing your image seems the 100% doesn't appear, because the margin is slimmer than default margin of WebChart. If is the case, I recommend you change the size of your margin left as I do in next line of code, because the labels can draw correctly:
Thanks,
I can try to reproduce your problem but it not occurs for me using last version of TeeChartFor.Net and next code:
Code: Select all
Steema.TeeChart.Chart tChart1;
protected void Page_Load(object sender, EventArgs e)
{
tChart1 = WebChart3.Chart;
InitializeChart();
}
private void InitializeChart()
{
tChart1.Aspect.View3D = false;
tChart1.Legend.Alignment = LegendAlignments.Bottom;
for (int i = 0; i < 2; i++)
{
new Steema.TeeChart.Styles.Line(tChart1.Chart);
tChart1[i].Marks.Visible = true;
AddValues(tChart1[i], 2);
tChart1[i].Marks.Style = Steema.TeeChart.Styles.MarksStyles.Percent;
}
tChart1.Axes.Left.GetAxisDrawLabel += new GetAxisDrawLabelEventHandler(Left_GetAxisDrawLabel);
tChart1.Axes.Bottom.MaximumOffset = 2;
tChart1.Axes.Bottom.MinimumOffset = 1;
tChart1.Axes.Left.MaximumOffset = 15;
tChart1.Axes.Left.MinimumOffset = 15;
tChart1.Axes.Left.SetMinMax(0, 100);
}
private void AddValues(Steema.TeeChart.Styles.Series s, int value)
{
Random rnd = new Random();
for (int i = 0; i < value; i++)
{
s.Add(i, rnd.Next(100));
}
}
void Left_GetAxisDrawLabel(object sender, GetAxisDrawLabelEventArgs e)
{
e.Text = e.Text + "%";
}
On the other hand, seeing your image seems the 100% doesn't appear, because the margin is slimmer than default margin of WebChart. If is the case, I recommend you change the size of your margin left as I do in next line of code, because the labels can draw correctly:
Code: Select all
tChart1.Panel.MarginLeft = 10;
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 |