TeeChart 如何更改标记字体
TeeChart how can I change marks font
我正在尝试制作一个简单的水平条形图,我快完成了,但是由于某些奇怪的原因,我找不到一种方法来更改系列条附近标记的字体属性(突出显示在屏幕)。
在这种特殊情况下,我需要使字体更大更易读。
我将通过下面的当前代码,如果你们中的任何人能指出正确的方向,我将不胜感激。
public static byte[] BarGraphHorizontal(double[] values, string[] names, Color[] colors,
int width, int height)
{
TChart chart = new TChart();
var series = new HorizBar();
series.Marks.Visible = true;
series.Marks.Style = MarksStyles.Percent;
series.Marks.Pen.Visible = false;
series.Marks.Font.Size = 20; // Shouldn't this do what I'm looking for?
series.Pen.Visible = false;
series.ColorEach = true;
var joinedInfo = values.Select((x, i) => new { Value = values[i], Name = names[i], Color = colors[i] })
.OrderBy(x => x.Value)
.ToArray();
for (int i = 0; i < joinedInfo.Length; i++)
{
series.Add(joinedInfo[i].Value, joinedInfo[i].Name);
series.Colors[i] = joinedInfo[i].Color;
}
var verticalLine = new ColorLine(chart.Chart);
verticalLine.Axis = chart.Axes.Bottom;
verticalLine.Value = 0;
verticalLine.Pen.Visible = true;
verticalLine.Pen.Color = Color.Black;
chart.Axes.Bottom.AxisPen.Visible = false;
chart.Axes.Bottom.Ticks.Visible = false;
chart.Axes.Bottom.MinorTicks.Visible = false;
chart.Axes.Bottom.Labels.ValueFormat = "0.0%";
chart.Axes.Bottom.Labels.Font.Size = 20;
chart.Axes.Left.Grid.Visible = false;
chart.Axes.Left.Labels.Font.Bold = true;
chart.Axes.Left.Labels.Font.Size = 20;
chart.Aspect.View3D = false;
chart.Header.Visible = false;
chart.Legend.Visible = false;
chart.Series.Add(series);
chart.Panel.Bevel.Inner = Steema.TeeChart.Drawing.BevelStyles.None;
chart.Panel.Bevel.Outer = Steema.TeeChart.Drawing.BevelStyles.None;
chart.Panel.Bevel.Width = 0;
chart.Panel.MarginRight *= 2;
chart.Graphics3D.BufferStyle = Steema.TeeChart.Drawing.BufferStyle.None;
using (var memoryStream = new MemoryStream())
{
chart.Export.Image.PNG.Width = width + 2;
chart.Export.Image.PNG.Height = height + 2;
chart.Export.Image.PNG.Save(memoryStream);
var result = memoryStream.ToArray();
result = Utils.RemoveBorder(result, 1);
return result;
}
}
好的,我找到了解决方案。
我需要将图表传递给 HorizBar
构造函数,在标记 属性 中所做的编辑会反映在图表中。
基本上函数的第一行变成了:
TChart chart = new TChart();
var series = new HorizBar(chart.Chart);
我正在尝试制作一个简单的水平条形图,我快完成了,但是由于某些奇怪的原因,我找不到一种方法来更改系列条附近标记的字体属性(突出显示在屏幕)。
在这种特殊情况下,我需要使字体更大更易读。
我将通过下面的当前代码,如果你们中的任何人能指出正确的方向,我将不胜感激。
public static byte[] BarGraphHorizontal(double[] values, string[] names, Color[] colors,
int width, int height)
{
TChart chart = new TChart();
var series = new HorizBar();
series.Marks.Visible = true;
series.Marks.Style = MarksStyles.Percent;
series.Marks.Pen.Visible = false;
series.Marks.Font.Size = 20; // Shouldn't this do what I'm looking for?
series.Pen.Visible = false;
series.ColorEach = true;
var joinedInfo = values.Select((x, i) => new { Value = values[i], Name = names[i], Color = colors[i] })
.OrderBy(x => x.Value)
.ToArray();
for (int i = 0; i < joinedInfo.Length; i++)
{
series.Add(joinedInfo[i].Value, joinedInfo[i].Name);
series.Colors[i] = joinedInfo[i].Color;
}
var verticalLine = new ColorLine(chart.Chart);
verticalLine.Axis = chart.Axes.Bottom;
verticalLine.Value = 0;
verticalLine.Pen.Visible = true;
verticalLine.Pen.Color = Color.Black;
chart.Axes.Bottom.AxisPen.Visible = false;
chart.Axes.Bottom.Ticks.Visible = false;
chart.Axes.Bottom.MinorTicks.Visible = false;
chart.Axes.Bottom.Labels.ValueFormat = "0.0%";
chart.Axes.Bottom.Labels.Font.Size = 20;
chart.Axes.Left.Grid.Visible = false;
chart.Axes.Left.Labels.Font.Bold = true;
chart.Axes.Left.Labels.Font.Size = 20;
chart.Aspect.View3D = false;
chart.Header.Visible = false;
chart.Legend.Visible = false;
chart.Series.Add(series);
chart.Panel.Bevel.Inner = Steema.TeeChart.Drawing.BevelStyles.None;
chart.Panel.Bevel.Outer = Steema.TeeChart.Drawing.BevelStyles.None;
chart.Panel.Bevel.Width = 0;
chart.Panel.MarginRight *= 2;
chart.Graphics3D.BufferStyle = Steema.TeeChart.Drawing.BufferStyle.None;
using (var memoryStream = new MemoryStream())
{
chart.Export.Image.PNG.Width = width + 2;
chart.Export.Image.PNG.Height = height + 2;
chart.Export.Image.PNG.Save(memoryStream);
var result = memoryStream.ToArray();
result = Utils.RemoveBorder(result, 1);
return result;
}
}
好的,我找到了解决方案。
我需要将图表传递给 HorizBar
构造函数,在标记 属性 中所做的编辑会反映在图表中。
基本上函数的第一行变成了:
TChart chart = new TChart();
var series = new HorizBar(chart.Chart);