This is a migrated thread and some comments may be shown as answers.

Rad chart on refresh confuse Y axis labels and scaling

1 Answer 111 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Luka
Top achievements
Rank 1
Luka asked on 18 Apr 2013, 11:42 AM
Hi!

Working with radchart I face with the problem that after I refresh the page (on which is my chart)  it's Y axis is strange.

My XAML:
<telerik:RadChart x:Name="durationChart" ItemsSource="{Binding DurationChart, Mode=TwoWay}">
    <telerik:RadChart.SeriesMappings>
        <telerik:SeriesMapping LegendLabel="Devices">
            <telerik:SeriesMapping.SeriesDefinition>
                <telerik:BarSeriesDefinition></telerik:BarSeriesDefinition>
            </telerik:SeriesMapping.SeriesDefinition>
            <telerik:SeriesMapping.ItemMappings>
                <telerik:ItemMapping DataPointMember="Label" FieldName="Value"></telerik:ItemMapping>
                <telerik:ItemMapping DataPointMember="YValue" FieldName="Value"></telerik:ItemMapping>
                <telerik:ItemMapping DataPointMember="XCategory" FieldName="Label"/>
            </telerik:SeriesMapping.ItemMappings>
        </telerik:SeriesMapping>
    </telerik:RadChart.SeriesMappings>
</telerik:RadChart>

Code-behind (declared in the constructor):
#region Duration Chart
 // Hide legend
 durationChart.DefaultView.ChartLegend.Visibility = Visibility.Collapsed;
 
 // Axis titles
 durationChart.DefaultView.ChartArea.AxisX.Title = MOD_COM_HLP.LocalizationHelper.LocalizeString(ResourceKeys.DLYPlantDelaysDurationXAxisResourceKey);
 durationChart.DefaultView.ChartArea.AxisY.Title = MOD_COM_HLP.LocalizationHelper.LocalizeString(ResourceKeys.DLYPlantDelaysDurationYAxisResourceKey);
 
 // X axis
 durationChart.DefaultView.ChartArea.AxisX.AxisLabelsVisibility = Visibility.Visible;
 durationChart.DefaultView.ChartArea.AxisX.PlotAreaAxisLabelsVisibility = Visibility.Visible;
 
 // Y axis
 durationChart.DefaultView.ChartArea.AxisY.AxisLabelsVisibility = Visibility.Visible;
 durationChart.DefaultView.ChartArea.AxisY.MajorTicksVisibility = Visibility.Visible;
 durationChart.DefaultView.ChartArea.AxisY.MinorTicksVisibility = Visibility.Hidden;
 #endregion

My binded OC for feeding the chart:
ObservableCollection<DLYChartPoint> durationChart = new ObservableCollection<DLYChartPoint>();

My refresh function does nothing more than clear the OC and rewrite the data for feed my chart:
private void FillDurationChart()
        {
            // Aux values
            List<LPD_COM_ENT.AUXValue> dlyDurationChartPeriods = lPDModulesLibraryProxy.ReadAUXValues(new LPDModulesLibrary.Common.Entities.ReadFilter() { VariableName = "DLY_DURATION_CHART_PERIOD"});
 
            if (Items == null) return;
 
            // Clear the chart
            DurationChart.Clear();
 
            // Add the columns
            foreach (LPD_COM_ENT.AUXValue variable in dlyDurationChartPeriods) {
                DLYChartPoint point = new DLYChartPoint() {Label = variable.CharValue, Value=0, UniqueId=variable.ValueSeq };
                DurationChart.Add(point);
            }
 
            // Fill chart
            foreach (DLYDelay stoppage in Items)
            {
                double duration = (stoppage.EndDelay - stoppage.StartDelay).TotalSeconds;
 
                foreach (LPD_COM_ENT.AUXValue variable in dlyDurationChartPeriods) {
                    if (duration >= variable.IntegerValue && duration < variable.FloatValue) {
                        DurationChart[(int)variable.ValueSeq].Value++;
                    }
                }
            }
        }

Thanks for all your replies.

Luka

1 Answer, 1 is accepted

Sort by
0
Missing User
answered on 23 Apr 2013, 06:44 AM
Hello Luka,

Thank you for the sample code you posted. Based on it, I was able to identify a possible cause for the problem. Make sure that the DLYChartPoint class you use implements INotifyPropertyChanged and it raises the PropertyChanged event whenever any of its properties' values are changed.

Let me know if this helps.

Kind regards,
Ivan N.
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
Chart
Asked by
Luka
Top achievements
Rank 1
Answers by
Missing User
Share this question
or