Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/272.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# MS图表显示自定义标签和隐藏轴标签_C#_Charts - Fatal编程技术网

C# MS图表显示自定义标签和隐藏轴标签

C# MS图表显示自定义标签和隐藏轴标签,c#,charts,C#,Charts,我正在VisualStudio2008(C#)中构建一个ASP.NET图表(System.Web.UI.DataVisualization.Charting.Chart),X轴上有自定义标签。我想隐藏自动生成的轴标签,只显示自定义标签。最好的方法是什么 如果我将轴属性LabelStyle.Enabled设置为false,则自定义标签也将隐藏 更新:通过将IntervalOffset属性设置为1000,它会将自动标签移出图表。但是,现在图表底部与自定义标签之间存在间隙。找到了答案:将自定义标签的R

我正在VisualStudio2008(C#)中构建一个ASP.NET图表(System.Web.UI.DataVisualization.Charting.Chart),X轴上有自定义标签。我想隐藏自动生成的轴标签,只显示自定义标签。最好的方法是什么

如果我将轴属性LabelStyle.Enabled设置为false,则自定义标签也将隐藏


更新:通过将IntervalOffset属性设置为1000,它会将自动标签移出图表。但是,现在图表底部与自定义标签之间存在间隙。

找到了答案:将自定义标签的RowIndex设置为0。现在一切都很好。

我已经用customlabel和tag列表解决了这个问题。我有两个功能:一个是添加customlabel列表,另一个是删除customlabel列表

    /// <summary>
    /// Add a list of CustomLabel to X Axis
    /// </summary>
    /// <param name="customLabelList">List of custom label</param>
    /// <param name="chartArea">Destination ChartArea</param>
    /// <param name="tag">Tag tha unique identify the custom label list</param>
    /// <param name="rowIndex"></param>
    public void AddAxisXCustomLabel(List<CustomLabel> customLabelList, string chartArea, string tag,int rowIndex)
    {
        foreach (CustomLabel cl in customLabelList)
        {
            cl.RowIndex = rowIndex;
            cl.Tag = tag;
            chart.ChartAreas[chartArea].AxisX.CustomLabels.Add(cl);
        }
    }
    /// <summary>
    /// Remove custom label from a list of custom label
    /// </summary>
    /// <param name="chartArea">Destination ChartArea</param>
    /// <param name="tag">Tag tha unique identify the custom label list</param>
    public void RemoveCustomLabelByTag(string chartArea,string tag)
    {
        for (int i = (chart.ChartAreas[chartArea].AxisX.CustomLabels.Count-1); i > -1; --i)
        { 
            CustomLabel cl = chart.ChartAreas[chartArea].AxisX.CustomLabels[i];
            if (cl.Tag.Equals(tag))
            {
                chart.ChartAreas[chartArea].AxisX.CustomLabels.RemoveAt(i);
            }
        }
     }
//
///将CustomLabel列表添加到X轴
/// 
///自定义标签列表
///目的地图表区
///标记用于标识自定义标签列表
/// 
public void AddAxisXCustomLabel(列出customLabelList、string chartArea、string标记、int rowIndex)
{
foreach(customLabelList中的CustomLabel cl)
{
cl.RowIndex=RowIndex;
cl.标签=标签;
chart.ChartAreas[chartArea].AxisX.CustomLabels.Add(cl);
}
}
/// 
///从自定义标签列表中删除自定义标签
/// 
///目的地图表区
///标记用于标识自定义标签列表
public void RemoveCustomLabelByTag(字符串图表区,字符串标记)
{
对于(int i=(chart.ChartAreas[chartArea].axix.CustomLabels.Count-1);i>-1;--i)
{ 
CustomLabel cl=chart.ChartAreas[chartArea].AxisX.CustomLabels[i];
如果(cl.标记等于(标记))
{
ChartAreas[chartArea].AxisX.CustomLabels.RemoveAt(i);
}
}
}
您可以使用


series.LabelForeColor=Color.Transparent

请向我们显示您的代码