Rad chart on refresh confuse Y axis labels and scaling

2 posts, 0 answers
  1. Luka
    Luka avatar
    7 posts
    Member since:
    Mar 2013

    Posted 18 Apr 2013 Link to this post

    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
  2. Missing user
    Missing user avatar

    Posted 23 Apr 2013 Link to this post

    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.

  3. UI for WPF is Visual Studio 2017 Ready
Back to Top