c# - 如何显示 StringLabelValue?

标签 c# .net teechart

我使用Teechart版本.Net & VS2005

日期和时间图形类型的X轴,点系列中添加了Y轴

我想显示StringLabelValue

我的代码:

private void GridPoint()
{
    datatable dt_point = new datatable();

    Steema.TeeChart.Styles.Points Pinpoint = new Steema.TeeChart.Styles.Points();
    TChart1.Series.Add(Pinpoint);

    Pinpoint.Pointer.Visible = false;
    Pinpoint.Pointer.InflateMargins = false;
    Pinpoint.Pointer.Transparency = 100;
    Pinpoint.Pointer.Pen.Visible = false;
    Pinpoint.Marks.Color = Color.White;
    Pinpoint.Marks.Pen.Color = Color.White;
    Pinpoint.Marks.Shadow.Visible = false;
    Pinpoint.Marks.Visible = true;

    Steema.TeeChart.Axis axis = new Steema.TeeChart.Axis();
    TChart1.Axes.Custom.Add(axis);

    axis.StartPosition = 9;
    axis.EndPosition = 9;

    axis.Labels.Items.Add(0, " ");
    axis.Labels.Items.Add(2000, " ");
    axis.Labels.Items[0].Visible = false;
    axis.Labels.Items[1].Visible = false;

    axis.Title.Caption = "";
    axis.Title.Font.Color = Color.Black;

    TChart1.Series[0].CustomVertAxis = axis;
    TChart1.Series[0].Clear();

    if (dt_Point.Columns.Count == 0)
    {
        dt_Point.Columns.Add("SetTime", typeof(DateTime));
        dt_Point.Columns.Add("Value", typeof(int));
        dt_Point.Columns.Add("Label", typeof(string));
    }

    DataRow row;
    row = dt_Point.NewRow();
    row["SetTime"] = "2012-08-02 18:14:24";
    row["Value"] = 100;
    row["Label"] = "Point";
    dt_Point.Rows.Add(row);

    TChart1.Series[0].XValues.DataMember = "SetTime";
    TChart1.Series[0].YValues.DataMember = "Value";
    TChart1.Series[0].DataMember = "Label";
    TChart1.Series[0].DataSource = dt_Point;
}

显示图表:

我想显示图表:

最佳答案

我建议您将XValues.DateTime设置为true并更改底部的DateTimeFormatStyle轴标签以获得您想要的结果:

//XValues as DateTimeValues.
Pinpoint.XValues.DateTime = true;

//Labels axes style and format 
tChart1.Axes.Bottom.Labels.DateTimeFormat = "hh:mm:ss";
tChart1.Axes.Bottom.Labels.Style = AxisLabelStyle.Value;

关于c# - 如何显示 StringLabelValue?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13391458/

相关文章:

c# - 如果我调用 C# 事件处理程序并调用它,会发生什么情况?

c# - 编译表达式树性能

c# - 列表框内的访问控件 c# (windows Phone 8)

Delphi7 TeeChart v4 图例 - 如何滚动?

.net - 如何使用 ClickOnce 安装 COM

c# - ASP.Net & EF Core 2 和并发 token 错误

c# - 从 .net 将图像写入每 channel 32 位(每像素 128 位)位图

.net - 分发给政府机构的 SSL 私钥是否足够安全

delphi - 在图表上设置左轴以将十进制值增加到0.13?

c# - 将在 using 语句中返回关键字,保持连接打开?