Note that there are some explanatory texts on larger screens.

plurals
  1. POSilverlight Toolkit chart control doesnt always show X axis values
    primarykey
    data
    text
    <p>I have an Silverlight 5 application which is using the Silverlight Toolkit. Now, the Silverlight Toolkit chart control doesnt always show X axis values when there is only one result in the resultset that returns from my webserivce. </p> <p><img src="https://i.stack.imgur.com/z7h68.png" alt="X-Axis works!!"> <img src="https://i.stack.imgur.com/Y3UBk.png" alt="With 1 item in the resultset, the X-Axis seems to disappear"></p> <p>The first image shows that my chart is loaded properly when selecting a big enough resultset. The second image shows that it doesn't when the resultset exists of 1 item.</p> <p>This is my implementation:</p> <pre><code>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() &amp;&amp; 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 &gt; monthSpan) { ((DateTimeAxis)lineSeries.IndependentAxis).IntervalType = DateTimeIntervalType.Days; ((DateTimeAxis)lineSeries.IndependentAxis).Interval = 5; } else if (graphSpan &gt; daySpan &amp;&amp; graphSpan &lt; monthSpan) { ((DateTimeAxis)lineSeries.IndependentAxis).IntervalType = DateTimeIntervalType.Days; ((DateTimeAxis)lineSeries.IndependentAxis).Interval = 1; } else if (graphSpan &gt; hourSpan &amp;&amp; graphSpan &lt; daySpan) { ((DateTimeAxis)lineSeries.IndependentAxis).IntervalType = DateTimeIntervalType.Hours; ((DateTimeAxis)lineSeries.IndependentAxis).Interval = 1; } else if (graphSpan &lt; 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); } } </code></pre> <p>Do you have any idea's? I'm out of possible solutions.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload