J'ai une application Silverlight 5 qui utilise Silverlight Toolkit. Maintenant, le contrôle de graphique Silverlight Toolkit n'affiche pas toujours les valeurs de l'axe X lorsqu'il n'y a qu'un seul résultat dans le jeu de résultats qui renvoie de ma Webserivce.Le contrôle du graphique Silverlight Toolkit n'affiche pas toujours les valeurs de l'axe X
La première image montre que mon tableau est correctement chargé lors de la sélection d'un assez grand ResultSet. La deuxième image montre que ce n'est pas le cas lorsque le jeu de résultats existe pour 1 élément.
Ceci est ma mise en œuvre:
TimeSpan monthSpan = TimeSpan.FromDays(30.0);
TimeSpan daySpan = TimeSpan.FromDays(1.0);
TimeSpan hourSpan = TimeSpan.FromHours(1.0);
foreach (TagValueResult res in e.NewItems)
{
if (res != null)
{
LineSeries lineSeries = new LineSeries()
{
Title = string.Format("{0}" + Environment.NewLine + " {2} ({1})", res.Name, res.Attributes["UOM"], res.Attributes["Description"]),
ItemsSource = res.Values,
DependentValueBinding = new System.Windows.Data.Binding("Value"),
IndependentValueBinding = new System.Windows.Data.Binding("Key"),
Tag = res,
PolylineStyle = Resources["thinLineStyle"] as Style,
//DataPointStyle = Resources["dataPointStyle"] as Style
};
if (res.Values.Any() && chart.Series.Any() == false)
{
TimeSpan graphSpan = res.Values.ToList().Last().Key - res.Values.ToList().First().Key;
lineSeries.IndependentAxis = new DateTimeAxis
{
Minimum = res.Values.ToList().First().Key,
Maximum = res.Values.ToList().Last().Key,
Interval = 1,
Orientation = AxisOrientation.X,
Location = AxisLocation.Bottom
};
if (graphSpan > monthSpan)
{
((DateTimeAxis)lineSeries.IndependentAxis).IntervalType = DateTimeIntervalType.Days;
((DateTimeAxis)lineSeries.IndependentAxis).Interval = 5;
}
else if (graphSpan > daySpan && graphSpan < monthSpan)
{
((DateTimeAxis)lineSeries.IndependentAxis).IntervalType = DateTimeIntervalType.Days;
((DateTimeAxis)lineSeries.IndependentAxis).Interval = 1;
}
else if (graphSpan > hourSpan && graphSpan < daySpan)
{
((DateTimeAxis)lineSeries.IndependentAxis).IntervalType = DateTimeIntervalType.Hours;
((DateTimeAxis)lineSeries.IndependentAxis).Interval = 1;
}
else if (graphSpan < hourSpan)
{
((DateTimeAxis)lineSeries.IndependentAxis).IntervalType = DateTimeIntervalType.Minutes;
((DateTimeAxis)lineSeries.IndependentAxis).Interval = 15;
}
else
{
//sometimes all comparisons fail, just back up to a safe interval of 1 day.
((DateTimeAxis)lineSeries.IndependentAxis).IntervalType = DateTimeIntervalType.Days;
((DateTimeAxis)lineSeries.IndependentAxis).Interval = 1;
}
}
chart.Series.Add(lineSeries);
}
}
Avez-vous une idée de? Je n'ai plus de solutions possibles.
Vous définissez la propriété 'Maximum' et la propriété' Minimum' de l'objet DateTimeAxis à la même valeur. – vorrtex