étiquette personnalisée sur l'axe des x

Mon tableau prédit une valeur pour les 30 prochaines années. La première valeur doit être affichée comme l'an 1. Puis l'année 5, 10... jusqu'au 30. Mais en interne, la première année est de 0 et est laissé de côté:

étiquette personnalisée sur l'axe des x

J'ai essayé d'ajouter une étiquette personnalisée, mais il ne le viole qu'à l'autre des étiquettes:
étiquette personnalisée sur l'axe des x

Si je l'ajoute à AxisX2 au lieu de AxisX il ne fait rien.
Voici le code pour faire de la charte et ajoutez les lignes:

public static Chart MakeChart(string title)
{
var chart = new Chart();
var area = new ChartArea("GrafiekGebied");
foreach (var axis in area.Axes)
{
axis.TitleForeColor = defaultColor;
axis.LineColor = defaultColor;
axis.InterlacedColor = defaultColor;
axis.LabelStyle.Font = letterType;
axis.LabelAutoFitMinFontSize = (int)letterType.Size;
axis.LabelAutoFitMaxFontSize = (int)letterType.Size;
axis.MajorGrid.LineColor = defaultColor;
axis.MajorTickMark.Enabled = false;
axis.MinorGrid.LineColor = defaultColor;
axis.MinorTickMark.LineColor = defaultColor;
}
CustomLabel firstXlabel = new CustomLabel();
firstXlabel.FromPosition = 0;
firstXlabel.ToPosition = 0;
firstXlabel.RowIndex = 0; //Also tried 1
firstXlabel.Text = "1jr";
area.AxisY.LineWidth = 0;
area.AxisY.LabelStyle.Format = "€{#,##}";
area.AxisX.TextOrientation = TextOrientation.Horizontal;
area.AxisX.CustomLabels.Add(firstXlabel); //Adding it to AxisX2 does nothing
area.AxisX.IsMarginVisible = true;
area.AxisX.MajorGrid.Enabled = false;
area.AxisX.IntervalOffset = 1;
area.AxisX.LabelStyle.Format = "{#}jr";
area.AxisX.MajorTickMark.Enabled = true;
area.AxisX2.LineWidth = 1;
area.AxisX2.LineColor = Color.Green;
var legend = new Legend();
legend.LegendStyle = LegendStyle.Row;
legend.Docking = Docking.Bottom;
legend.DockedToChartArea = area.Name;
legend.Font = lettering;
legend.IsDockedInsideChartArea = false;
chart.ForeColor = defaultColor;
chart.Font.Name = lettering.FontFamily.Name;
chart.Font.Size = new System.Web.UI.WebControls.FontUnit(lettering.Size);
chart.Width = 280;
chart.Height = 180;
chart.Legends.Add(legend);
chart.ChartAreas.Add(area);
chart.BorderlineColor = defaultColor;
chart.BorderlineWidth = 1;
chart.BorderlineDashStyle = ChartDashStyle.Solid;
chart.Titles.Add(title);
return chart;
}
public static void AddData(Chart chart, ChartInput input)
{
var line = new Series(input.Subtitle);
line.ChartArea = chart.ChartAreas[0].Name;
line.ChartType = SeriesChartType.Spline;
line.Color = input.Color;
line.BorderWidth = 3;
line.MarkerStyle = MarkerStyle.Circle;
line.MarkerSize = 7;
line.MarkerStep = 5;
for (int i = 0; i < input.Waarden.Length; i++)
{
line.Points.AddXY(i, input.Values[i]);
}
chart.Series.Add(line);
}

Après le graphique, il est inséré dans un document word à l'aide de Aspose, mais qui ne devrait pas question pour savoir comment le tableau est fait.

Avez-vous l'endroit qui vous fait firstXlabel.FromPosition = 0; et firstXlabel.La position ğtopositionğ = 0; la même valeur. Avez-vous essayer de faire le la position ğtopositionğ dire l'entrée.Waarden.Longueur?
Bonne idée. Cependant, je ne travaille pas on plus et n'ont pas accès à la base de code. Ne me souviens pas comment j'ai résolu le problème.

OriginalL'auteur MrFox | 2013-09-20