Legend with Continous = true and formatting of legind text
Legend with Continous = true and formatting of legind text
Hi,
1) How do I get the legend to span the entire ChartRect.Height? as shown in the attached graphs, it only spans the top of the chart?
2) How do I format the legend text so that it becomes - for instance - 128,6 instead of 128,577 ??
1) How do I get the legend to span the entire ChartRect.Height? as shown in the attached graphs, it only spans the top of the chart?
2) How do I format the legend text so that it becomes - for instance - 128,6 instead of 128,577 ??
- Attachments
-
- unknown.JPEG (180.93 KiB) Viewed 18288 times
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Re: Legend with Continous = true and formatting of legind text
Hi Friis,
1. What about something like this?
2. You can modify legend text format in the GetLegenText event, for example:
1. What about something like this?
Code: Select all
public Form1()
{
InitializeComponent();
InitializeChart();
}
private void InitializeChart()
{
tChart1.Series.Add(new ColorGrid()).FillSampleValues();
tChart1.GetLegendRect += tChart1_GetLegendRect;
tChart1.Legend.Symbol.Continous = true;
tChart1.Legend.Font.Size = 14;
}
void tChart1_GetLegendRect(object sender, GetLegendRectEventArgs e)
{
Rectangle chartRect = this.tChart1.Chart.ChartRect;
e.Rectangle = new Rectangle(e.Rectangle.Left, chartRect.Top, e.Rectangle.Width, chartRect.Height);
}
Code: Select all
void tChart1_GetLegendText(object sender, GetLegendTextEventArgs e)
{
double tmp = Convert.ToDouble(e.Text);
e.Text = tmp.ToString("0.000");
}
Best Regards,
Narcís Calvet / 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: Legend with Continous = true and formatting of legind text
Hi,
1) This does not solve the problem - try to test the code I have made below on your system - can you reproduce the problem?
2) Thank you - I will use this
1) This does not solve the problem - try to test the code I have made below on your system - can you reproduce the problem?
2) Thank you - I will use this
Code: Select all
public Form1()
{
InitializeComponent();
Make3DGraph();
}
public void Make3DGraph()
{
try
{
this.tChart1.Series.Clear();
this.tChart1.Series.RemoveAllSeries();
this.tChart1.Dock = DockStyle.Fill;
this.tChart1.BackColor = Color.White;
this.tChart1.Walls.Back.Gradient.Visible = false;
this.tChart1.Walls.Back.Color = Color.White;
this.tChart1.Walls.Bottom.Gradient.Visible = false;
this.tChart1.Walls.Bottom.Color = Color.White;
this.tChart1.Panel.Gradient.Visible = false;
this.tChart1.Panel.Color = Color.White;
this.tChart1.Aspect.View3D = false;
this.tChart1.Panel.Bevel.Outer = Steema.TeeChart.Drawing.BevelStyles.None;
this.tChart1.Axes.Left.Automatic = true;
this.tChart1.Axes.Bottom.Automatic = true;
this.tChart1.Axes.Left.Title.Caption = "";
this.tChart1.Axes.Bottom.Title.Caption = "";
this.tChart1.Header.Text = "";
this.tChart1.Header.Font.Size = 14;
this.tChart1.Legend.VertSpacing = 0;
this.tChart1.Legend.Symbol.Width = 100;
this.tChart1.Legend.Transparent = false;
this.tChart1.Legend.Symbol.DefaultPen = false;
this.tChart1.Legend.Symbol.Continous = true;
this.tChart1.Legend.Symbol.Pen.Color = Color.White;
this.tChart1.Legend.Symbol.Pen.Width = 1;
this.tChart1.Legend.DividingLines.Visible = false;
this.tChart1.Legend.Symbol.Width = 50;
this.tChart1.Legend.Symbol.Squared = true;
this.tChart1.Legend.Visible = true;
this.tChart1.Legend.Shadow.Visible = true;
this.tChart1.Legend.Font.Size = 14;
this.tChart1.Axes.Left.Title.Text = "Power / MW";
this.tChart1.Axes.Left.Title.Font.Size = 14;
this.tChart1.Axes.Bottom.Title.Text = "Q / MJ/s";
this.tChart1.Axes.Bottom.Title.Font.Size = 14;
Steema.TeeChart.Styles.ColorGrid ColorGridSeries1 = new Steema.TeeChart.Styles.ColorGrid(tChart1.Chart);
this.tChart1.Series.Add(ColorGridSeries1);
ColorGridSeries1.Pen.Visible = false;
ColorGridSeries1.Title = "surface1";
ColorGridSeries1.UseColorRange = false;
ColorGridSeries1.UsePalette = true;
ColorGridSeries1.IrregularGrid = true;
ColorGridSeries1.CenteredPoints = true;
for (double x = 0; x < 10; x += 0.1) // = 10 rows
for (double z = 0; z < 10; z += 0.1) // = 10 columns
ColorGridSeries1.Add(x, x*z, z);
ColorGridSeries1.Pen.Visible = false;
ColorGridSeries1.UsePalette = true;
Color[] ColorPalette = new Color[100];
double[] ColorSteps;
ColorPalette = SetColorPalette(1, out ColorSteps);
for (int i = 0; i < ColorPalette.Length; i++)
ColorGridSeries1.AddPalette(ColorSteps[i], ColorPalette[i]);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
private Color[] SetColorPalette(byte Index, out double[] ColorSteps)
{
double max;
double min;
Color[] ColorPalette = new Color[100];
ColorSteps = new double[100];
ColorSteps[0] = 0;
ColorPalette[0] = Color.White;
for (int i = 1; i < 100; i++)
ColorPalette[i] = CoolColorCode(i);
for (int i = 1; i < ColorPalette.Length; i++)
ColorSteps[i] = i;
return ColorPalette;
}
private void tChart1_GetLegendRect(object sender, Steema.TeeChart.GetLegendRectEventArgs e)
{
Rectangle chartRect = this.tChart1.Chart.ChartRect;
e.Rectangle = new Rectangle(e.Rectangle.Left, chartRect.Top, e.Rectangle.Width, chartRect.Height);
}
private Color CoolColorCode(double ColorValue)
{
ColorValue = 100 - ColorValue;
if (ColorValue < 0)
ColorValue = 0;
else if (ColorValue > 100)
ColorValue = 100;
if (ColorValue < 25)
return Color.FromArgb(255, Convert.ToInt16(ColorValue / 25 * 255), 0);
else if (ColorValue < 50)
return Color.FromArgb(Convert.ToInt16(255 - ((ColorValue - 25) / 25 * 255)), 255, 0);
else if (ColorValue < 75)
return Color.FromArgb(0, 255, Convert.ToInt16((ColorValue - 50) / 25 * 255));
else
return Color.FromArgb(0, Convert.ToInt16(255 - Math.Round((ColorValue - 75) / 25 * 255)), 255);
}
Re: Legend with Continous = true and formatting of legind text
1) Perhaps I'm not explaining the problem well enough. The blue squared symbol with a value of 15.175 in the attached image "unknown.jpeg" - I would like to have that moved down to the very bottom and the red squared symbol with a value of 128.577 to stay at the top. In that way do make the legend values show a larger range of values and colors
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Re: Legend with Continous = true and formatting of legind text
Hi Friis,
1. This highly depends on the chart size. Another variable you can throw into the mix is Legend.VertSpacing:
You can make those values relative to the chart height.
1. This highly depends on the chart size. Another variable you can throw into the mix is Legend.VertSpacing:
Code: Select all
this.tChart1.Legend.VertSpacing = 10;
Best Regards,
Narcís Calvet / 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: Legend with Continous = true and formatting of legind text
Hi Narcis,
OK, vertspacing makes it look a little better...
But, for instance, in the attached image "unknown.jpeg" there are 10 symbols ranging from 0 to 128.577 - isn't it possible to increase this number to a larger number so that you accomplish a smoother gradient and larger gradient?
for instance, in the attached image "untitled.jpg" the legend is very smooth and there are an "unlimited" amounts of symbols ??
OK, vertspacing makes it look a little better...
But, for instance, in the attached image "unknown.jpeg" there are 10 symbols ranging from 0 to 128.577 - isn't it possible to increase this number to a larger number so that you accomplish a smoother gradient and larger gradient?
for instance, in the attached image "untitled.jpg" the legend is very smooth and there are an "unlimited" amounts of symbols ??
- Attachments
-
- untitled.jpg (21.86 KiB) Viewed 18222 times
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Re: Legend with Continous = true and formatting of legind text
Hi Friis,
You'd better use LegendPalette tool for that. You'll find an example at "All Features\Welcome !\Tools\Legend Palette" in the features demo available at TeeChart's program group. This applied to your example:
You'd better use LegendPalette tool for that. You'll find an example at "All Features\Welcome !\Tools\Legend Palette" in the features demo available at TeeChart's program group. This applied to your example:
Code: Select all
public Form1()
{
InitializeComponent();
InitializeChart();
}
private void InitializeChart()
{
this.tChart1.Series.Clear();
this.tChart1.Series.RemoveAllSeries();
this.tChart1.Dock = DockStyle.Fill;
this.tChart1.BackColor = Color.White;
this.tChart1.Walls.Back.Gradient.Visible = false;
this.tChart1.Walls.Back.Color = Color.White;
this.tChart1.Walls.Bottom.Gradient.Visible = false;
this.tChart1.Walls.Bottom.Color = Color.White;
this.tChart1.Panel.Gradient.Visible = false;
this.tChart1.Panel.Color = Color.White;
this.tChart1.Aspect.View3D = false;
this.tChart1.Panel.Bevel.Outer = Steema.TeeChart.Drawing.BevelStyles.None;
this.tChart1.Axes.Left.Automatic = true;
this.tChart1.Axes.Bottom.Automatic = true;
this.tChart1.Axes.Left.Title.Caption = "";
this.tChart1.Axes.Bottom.Title.Caption = "";
this.tChart1.Header.Text = "";
this.tChart1.Header.Font.Size = 14;
this.tChart1.Legend.VertSpacing = 0;
this.tChart1.Legend.Symbol.Width = 100;
this.tChart1.Legend.Transparent = false;
this.tChart1.Legend.Symbol.DefaultPen = false;
this.tChart1.Legend.Symbol.Continous = true;
this.tChart1.Legend.Symbol.Pen.Color = Color.White;
this.tChart1.Legend.Symbol.Pen.Width = 1;
this.tChart1.Legend.DividingLines.Visible = false;
this.tChart1.Legend.Symbol.Width = 50;
this.tChart1.Legend.Symbol.Squared = true;
this.tChart1.Legend.Visible = true;
this.tChart1.Legend.Shadow.Visible = true;
this.tChart1.Legend.Font.Size = 14;
this.tChart1.Legend.VertSpacing = 10;
this.tChart1.Axes.Left.Title.Text = "Power / MW";
//this.tChart1.Axes.Left.Title.Font.Size = 14;
this.tChart1.Axes.Bottom.Title.Text = "Q / MJ/s";
//this.tChart1.Axes.Bottom.Title.Font.Size = 14;
Steema.TeeChart.Styles.ColorGrid ColorGridSeries1 = new Steema.TeeChart.Styles.ColorGrid(tChart1.Chart);
this.tChart1.Series.Add(ColorGridSeries1);
ColorGridSeries1.Pen.Visible = false;
ColorGridSeries1.Title = "surface1";
ColorGridSeries1.UseColorRange = false;
ColorGridSeries1.UsePalette = true;
ColorGridSeries1.IrregularGrid = true;
ColorGridSeries1.CenteredPoints = true;
for (double x = 0; x < 10; x += 0.1) // = 10 rows
for (double z = 0; z < 10; z += 0.1) // = 10 columns
ColorGridSeries1.Add(x, x * z, z);
ColorGridSeries1.Pen.Visible = false;
ColorGridSeries1.UsePalette = true;
Color[] ColorPalette = new Color[100];
double[] ColorSteps;
ColorPalette = SetColorPalette(1, out ColorSteps);
for (int i = 0; i < ColorPalette.Length; i++)
ColorGridSeries1.AddPalette(ColorSteps[i], ColorPalette[i]);
legendPalette1 = new LegendPalette(tChart1.Chart);
legendPalette1.Series = ColorGridSeries1;
tChart1.Legend.Visible = false;
tChart1.GetAxesChartRect += tChart1_GetAxesChartRect;
tChart1.Panel.MarginUnits = PanelMarginUnits.Pixels;
tChart1.Panel.MarginRight = legendPalette1.Width + 10;
}
private Steema.TeeChart.Tools.LegendPalette legendPalette1;
void tChart1_GetAxesChartRect(object sender, GetAxesChartRectEventArgs e)
{
legendPalette1.PositionUnits = PositionUnits.Pixels;
legendPalette1.Top = e.AxesChartRect.Top;
legendPalette1.Left = e.AxesChartRect.Right + 5;
legendPalette1.Height = e.AxesChartRect.Height;
}
private Color[] SetColorPalette(byte Index, out double[] ColorSteps)
{
Color[] ColorPalette = new Color[100];
ColorSteps = new double[100];
ColorSteps[0] = 0;
ColorPalette[0] = Color.White;
for (int i = 1; i < 100; i++)
ColorPalette[i] = CoolColorCode(i);
for (int i = 1; i < ColorPalette.Length; i++)
ColorSteps[i] = i;
return ColorPalette;
}
private Color CoolColorCode(double ColorValue)
{
ColorValue = 100 - ColorValue;
if (ColorValue < 0)
ColorValue = 0;
else if (ColorValue > 100)
ColorValue = 100;
if (ColorValue < 25)
return Color.FromArgb(255, Convert.ToInt16(ColorValue / 25 * 255), 0);
else if (ColorValue < 50)
return Color.FromArgb(Convert.ToInt16(255 - ((ColorValue - 25) / 25 * 255)), 255, 0);
else if (ColorValue < 75)
return Color.FromArgb(0, 255, Convert.ToInt16((ColorValue - 50) / 25 * 255));
else
return Color.FromArgb(0, Convert.ToInt16(255 - Math.Round((ColorValue - 75) / 25 * 255)), 255);
}
Best Regards,
Narcís Calvet / 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: Legend with Continous = true and formatting of legind text
Hi,
That looks MUCH better - Thank you
However, if I set the
this looks strange - the font at the legend palette looks bold ??
That looks MUCH better - Thank you
However, if I set the
Code: Select all
legendPalette1.Transparent = false;
- Attachments
-
- StrangeLookingLegendPalette.png (7.68 KiB) Viewed 18205 times
-
- LegendPaletteOK but not transparent.png (8.08 KiB) Viewed 18214 times
-
- Site Admin
- Posts: 14730
- Joined: Mon Jun 09, 2003 4:00 am
- Location: Banyoles, Catalonia
- Contact:
Re: Legend with Continous = true and formatting of legind text
Hi Friis,
This looks like a bug to me. I have added it (ID971) to the bug list to be fixed for future releases.
This looks like a bug to me. I have added it (ID971) to the bug list to be fixed for future releases.
Best Regards,
Narcís Calvet / 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: Legend with Continous = true and formatting of legind text
Hi Again,
How do I add a title to the legendPalette?
The following code does not work?
and
just adds a title to the chart itself ?
How do I add a title to the legendPalette?
The following code does not work?
Code: Select all
legendPalette1.title.text = "sasasf";
Code: Select all
legendPalette1.chart.header.text = "dsf";
-
- Guru
- Posts: 1603
- Joined: Fri Nov 15, 2002 12:00 am
Re: Legend with Continous = true and formatting of legind text
Yes; in the meantime, a simple workaround is this:Narcís wrote:This looks like a bug to me. I have added it (ID971) to the bug list to be fixed for future releases.
Code: Select all
private void InitializeChart()
{
tChart1.Series.Add(new ColorGrid()).FillSampleValues();
Steema.TeeChart.Tools.LegendPalette legendPalette1 = new LegendPalette(tChart1.Chart);
legendPalette1.Series = tChart1[0];
legendPalette1.Axes.Chart.Graphics3D.TextRenderingHint = System.Drawing.Text.TextRenderingHint.SystemDefault;
legendPalette1.Transparent = true;
}
Best Regards,
Christopher Ireland / 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 |
-
- Guru
- Posts: 1603
- Joined: Fri Nov 15, 2002 12:00 am
Re: Legend with Continous = true and formatting of legind text
Try:Friis wrote:just adds a title to the chart itself ?
Code: Select all
legendPalette1.Axes.Chart.Header.Visible = true;
legendPalette1.Axes.Chart.Header.Text = "asasas";
Best Regards,
Christopher Ireland / 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: Legend with Continous = true and formatting of legind text
Just implemented both of the solutions you have presented here - it works fantastic both of them - thank you