TeeChart如何更改标记字体

问题描述 投票:0回答:1

我正在尝试制作一个简单的水平条形图,但是我几乎完成了,但是由于某种奇怪的原因,我找不到一种方法来更改系列条形图附近标记的字体属性(在屏幕上突出显示) 。

在这种情况下,我需要使字体更大并且更具可读性。

Graph ATM

我会跳过下面的当前代码,如果你们中的任何一个可以向我指出正确的方向,我们将不胜感激。

        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;
            }
        }
c# teechart
1个回答
0
投票

确定我找到了解决方法。

我需要将图表传递给HorizBar构造函数,并将在Marks属性中所做的编辑反映在图表中。

基本上该函数的第一行变成:

    TChart chart = new TChart();
    var series = new HorizBar(chart.Chart);
© www.soinside.com 2019 - 2024. All rights reserved.