Telerik Forums
UI for WPF Forum
2 answers
104 views
Hi,
I am adding 2  DataSeries into DefaultView.ChartArea, but only one of them shown in a time.
How I can show, data series together in a time in one rad chart ?
ConfigureMonthlySales(radchart.DefaultView.ChartArea, lsdata1);
ConfigureMonthlySales(radchart.DefaultView.ChartArea, lsdata2);
.....
.....
 
private void ConfigureMonthlySales(ChartArea chartArea, List<KeyValuePair<string, double>> lsData)
        {
            DataSeries doughnutSeries = new DataSeries();
 
            foreach (KeyValuePair<string, double> data in lsData)
            {
                DataPoint point = new DataPoint();
                point.YValue = data.Value;
                point.LegendLabel = data.Key;
                doughnutSeries.Add(point);
            }
 
            doughnutSeries.Definition = new DoughnutSeriesDefinition();
 
            ((DoughnutSeriesDefinition)doughnutSeries.Definition).LabelSettings.LabelOffset = 0.7d;
            doughnutSeries.Definition.ItemLabelFormat = "#%{p0}";
            doughnutSeries.Definition.ShowItemToolTips = true;
            chartArea.DataSeries.Add(doughnutSeries);
             
            chartArea.SmartLabelsEnabled = false;
        }


Thanks
A Mahdavi
Top achievements
Rank 1
 answered on 06 Nov 2010
10 answers
445 views
Hello Telerik,

I have a few problems with the chart.
Attached NO example. (!! we are unable to attach zip files)

Flickering:
When i set the 'DefaultView.ChartArea.AxisY.AutoRange' to TRUE, the chart flickers,
when set it to FALSE and specify the min/max/step value it does not have this problem,
but .... i would like to use the AutoRange function :)

Horizontal scroll/zoom:
- I cannot get this working, i think when setting the min/max values for the X axis, everything is reset?
  Is there a solution for this behavior?
- When i start the application and press ALT-F4 (to close the application), it works,
  when i first try to scroll/zoom the horizontal bar (or clicking on the slider), i cannot press ALT-F4 again, or any other common keyboard shortcuts.

With kind regards,
Rob

As we are unable to attach ZIP files, here the .cs code for the window (it only has one radchart)

Window.xaml
<Window x:Class="TelerikChart.Window1" 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:telerikChart="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Charting" 
    Title="Window1" Height="600" Width="800" 
    Loaded="OnLoaded" 
        > 
    <Grid> 
        <Grid.Resources> 
            <Style x:Key="ItemLabelStyle" TargetType="TextBlock"
                <Setter Property="Foreground" Value="Orange" /> 
            </Style> 
        </Grid.Resources> 
        <telerikChart:RadChart x:Name="RadChart1" /> 
    </Grid> 
</Window> 
 


Window.xaml.cs
using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Text; 
using System.Windows; 
using System.Windows.Controls; 
using System.Windows.Data; 
using System.Windows.Documents; 
using System.Windows.Input; 
using System.Windows.Media; 
using System.Windows.Media.Imaging; 
using System.Windows.Navigation; 
using System.Windows.Shapes; 
using Telerik.Windows.Controls.Charting; 
using System.Windows.Threading; 
 
namespace TelerikChart 
    /// <summary> 
    /// Interaction logic for Window1.xaml 
    /// </summary> 
    public partial class Window1 : Window 
    { 
        private DateTime nowTime = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, DateTime.Now.Hour, DateTime.Now.Minute, DateTime.Now.Second); 
 
        private const int queueCapacity = 3600; 
        private RadHierarchicalObservableCollection<ValueLoadInfo> ChartData = new RadHierarchicalObservableCollection<ValueLoadInfo>(); 
        private Random rnd = new Random(); 
        private DispatcherTimer timer1 = null
 
        public Window1() 
        { 
            InitializeComponent(); 
 
            //Setup Chart 
            RadChart1.DefaultView.ChartTitle.Content = "Legend Title"
            RadChart1.DefaultView.ChartArea.NoDataString = "Waiting for data..."
            RadChart1.DefaultView.ChartArea.EnableAnimations = false
 
            //Setup X-As 
            RadChart1.DefaultView.ChartArea.AxisX.DefaultLabelFormat = "#VAL{HH:mm:ss}"
            RadChart1.DefaultView.ChartArea.AxisX.LabelRotationAngle = 90; 
            RadChart1.DefaultView.ChartArea.AxisX.LabelStep = 2; 
            RadChart1.DefaultView.ChartArea.AxisX.Title = "Time"
            RadChart1.DefaultView.ChartArea.AxisX.LayoutMode = AxisLayoutMode.Normal; 
            RadChart1.DefaultView.ChartArea.AxisX.AutoRange = false
 
            //Setup Y-As 
            RadChart1.DefaultView.ChartArea.AxisY.AutoRange = false
            RadChart1.DefaultView.ChartArea.AxisY.MinValue = 38000; 
            RadChart1.DefaultView.ChartArea.AxisY.MaxValue = 38001; 
            RadChart1.DefaultView.ChartArea.AxisY.Step = 0.100; 
            RadChart1.DefaultView.ChartArea.AxisY.AxisName = "Value"
            RadChart1.DefaultView.ChartArea.AxisY.DefaultLabelFormat = "#VAL{0.000}"
            RadChart1.DefaultView.ChartArea.AxisY.Title = "Value (double)"
 
            //Setup mapping 
            SeriesMapping memoryDataMapping = new SeriesMapping(); 
            memoryDataMapping.LegendLabel = "My Label"
            memoryDataMapping.SeriesDefinition = new LineSeriesDefinition(); 
            (memoryDataMapping.SeriesDefinition as LineSeriesDefinition).ShowPointMarks = false
            (memoryDataMapping.SeriesDefinition as LineSeriesDefinition).ShowItemLabels = false
            memoryDataMapping.SeriesDefinition.AxisName = "Value"
            memoryDataMapping.ItemMappings.Add(new ItemMapping("Time", DataPointMember.XValue)); 
            memoryDataMapping.ItemMappings.Add(new ItemMapping("Value", DataPointMember.YValue)); 
            RadChart1.SeriesMappings.Add(memoryDataMapping); 
 
            //Could not find Resource 'ItemLabelStyle' 
             
            RadChart1.DefaultView.ChartArea.ZoomScrollSettingsX.ScrollMode = ScrollMode.ScrollAndZoom; 
 
            //RadChart1.DefaultView.ChartLegend.Visibility = Visibility.Collapsed;  
         
        } 
 
        private void OnLoaded(object sender, RoutedEventArgs e) 
        { 
            //Start timer 
            timer1 = new DispatcherTimer(); 
            timer1.Interval = TimeSpan.FromMilliseconds(300); 
            timer1.Tick += timer1_Tick; 
            timer1.Start(); 
        } 
 
        private void SetUpAxisXRange(DateTime now) 
        { 
            if (this.ChartData.Count() > 0) 
            { 
                RadChart1.DefaultView.ChartArea.AxisX.MinValue = ChartData[0].Time.ToOADate(); 
                RadChart1.DefaultView.ChartArea.AxisX.MaxValue = now.ToOADate(); 
 
                double Range = RadChart1.DefaultView.ChartArea.AxisX.MaxValue - RadChart1.DefaultView.ChartArea.AxisX.MinValue; 
                RadChart1.DefaultView.ChartArea.AxisX.Step = Range / 10.0; 
            } 
        } 
 
        private void timer1_Tick(object sender, EventArgs e) 
        { 
            if (this.ChartData.Count >= queueCapacity) 
                this.ChartData.RemoveAt(0); 
 
            this.nowTime = this.nowTime.AddMilliseconds(300); 
 
            ValueLoadInfo systemInfo = new ValueLoadInfo(); 
 
            systemInfo.Value = 38000 + (rnd.NextDouble()%1000); 
            systemInfo.Time = this.nowTime; 
            this.ChartData.Add(systemInfo); 
 
            this.SetUpAxisXRange(this.nowTime); 
 
            if (RadChart1.ItemsSource == null
                RadChart1.ItemsSource = this.ChartData; 
        } 
    } 
    public class ValueLoadInfo 
    { 
        private DateTime _time; 
        private double _Value; 
        public DateTime Time 
        { 
            get { return this._time; } 
            set { this._time = value; } 
        } 
        public double Value 
        { 
            get { return this._Value; } 
            set { this._Value = value; } 
        } 
    } 
 
 

Ves
Telerik team
 answered on 05 Nov 2010
2 answers
106 views
How do I change the celltype/celledittype on autogenerated columns?
I've done the following but it doesn't work.  It assigned the template, but doesn't seem to display the template.

private void fullyLoadedCostListRadGridView_AutoGeneratingColumn(object sender, GridViewAutoGeneratingColumnEventArgs e) {
    e.Column.CellTemplate = (DataTemplate)FindResource("telerikContentColumnTemplate");
}
David Brenchley
Top achievements
Rank 1
 answered on 05 Nov 2010
3 answers
287 views
I am editing a row in a RadGridView (WPF -- form application). I want to use the CellEditEnded event, when they are done editing a particular cell, I want to move the focus back to a textbox on the form. When the user hits Tab the CellEditEnded event fires and that seems to be the even to use.

I can trap for the column and when I call txtProductCode.Focus(); nothing happens. When I hit tab again the next cell in the same grid row has focus. So it is behaves like it needs to 'leave' the grid first.

Any thoughts?

private void gvCount_CellEditEnded(object sender, Telerik.Windows.Controls.GridViewCellEditEndedEventArgs e)
{
    //if edit editing on Quantity cell, then position focus to product code -- edit end typically comes from when tab key is clicked
    if (e.Cell.Column.UniqueName == "Quantity")
    {
        txtProductCode.Focus();
    }
}
Maya
Telerik team
 answered on 05 Nov 2010
6 answers
230 views
Hello,

We are binding a RadGridView to a property (Observable Collection of Entities) in an MVVM scenario. Within this grid we have a GridViewCheckBoxColumn that has a DataMemberBinding to a string property within our entities. Since the string is always "0" or "1" we use a ValueConverter to convert to Boolean - True/False in order to tick the checkbox. We found that the converter always calls the "Convert" method instead of the "ConvertBack" upon setting the value....

For test purposes we were binding a standard GridViewDataColumn to the same converter to ensure it is working properly which it does....

Example:
    <Grid> 
        <Grid.RowDefinitions> 
            <RowDefinition Height="0.913*"/>  
        </Grid.RowDefinitions> 
        <Expander Grid.Row="1" 
            Header="Berthing Slots" 
            IsExpanded="True" 
            VerticalAlignment="Top" Margin="0,4.988,0,0">  
            <telerik:RadGridView x:Name="radBerthingSlots" 
                AutoGenerateColumns="False" 
                IsEnabled="True" 
                ItemsSource="{Binding BerthingSlots}" 
                SelectedItem="{Binding SelectedBerthingSlot, Mode=TwoWay}"   
                AddingNewDataItem="radBerthingSlots_AddingNewDataItem"   
                RowEditEnded="radBerthingSlots_RowEditEnded" Deleting="radBerthingSlots_Deleting">  
                  
                <telerik:RadGridView.Columns> 
                    <telerik:GridViewCheckBoxColumn Header="Available" DataMemberBinding="{Binding Path=HtDiff, Converter={StaticResource HtDiffNumberConverter}, Mode=TwoWay}" /> 
                    <telerik:GridViewDataColumn Header="HT Diff" DataMemberBinding="{Binding Path=HtDiff, Converter={StaticResource HtDiffNumberConverter}, Mode=TwoWay}" /> 
                </telerik:RadGridView.Columns> 
            </telerik:RadGridView> 
    </Grid> 
 

Now, when we change the value in the GridViewDataColumn the "ConvertBack" method is correctly (as expected) invoked....

When we do the same (ticking / unticking the checkbox on the GridViewCheckBoxColumn) it always calls the "Convert" method.....

Clearly that can't be right.... can you guys please help!

Many Thanks in advance.....

Regards

M.
Marco Barzaghi
Top achievements
Rank 1
 answered on 05 Nov 2010
3 answers
105 views
This works (default Microsoft toolbar):

        <ToolBar ItemsSource="{Binding Path=Actions}"></ToolBar>

This does not:

        <telerik:RadToolBar ItemsSource="{Binding Path=Actions}"></telerik:RadToolBar>

What i get is number of items x 2 when the toolbar is shown.

I notice that there are multiple questions revolving around this issue, but they are old. Is this still a problem in Telerik WPF controls, or am I missing something?
Viktor Tsvetkov
Telerik team
 answered on 05 Nov 2010
2 answers
145 views
I'm trying to force the row details presenter of my grid to be the full width of its parent row. This has actually has two parts to it. All my grids seem to have a column at the far left of the grid that I can't seem to remove. After that the grid in my row details seems to only take up as much room as it needs, it never expands to the space available. Its a bit difficult to explain so I've attached a screen shot of my problem. Hopefully someone can point me in the right direction!

Thanks
Rossen Hristov
Telerik team
 answered on 05 Nov 2010
1 answer
167 views
How do you set the DatePicker to show a blank / null date.

I have an intial value for datepicker but then I need to set the DatePicker to blank/null

I can set SelectedDate = null - but the display date stays the same

this

 

.calPaydate.SelectedDate = null;
this.calPayDate.displaydate =   ?????

thx

 

Kaloyan
Telerik team
 answered on 05 Nov 2010
2 answers
129 views
I'm trialing the latest version of Telerik 2010.2 WPF. So my experience with the toolkit is limited. I'm having the following problem:

I'm using XmlDataProvider as the data source. One of the elements of the XML file contains dates
    <Date>2010-10-30T01:01:01.0000000+08:00</Date>
I got around of the problem displaying those dates in a user friendly manner by handling AutoGeneratingColumn event and assigning a value converter to the Date column.

But what about filtering? I need to be able to filter the dates. I've tried to create a filter and specify member type as DateTime by for obvious reason the grid fails with invalid object type exception

var dtFilter = new FilterDescriptor("Date", FilterOperator.IsGreaterThanOrEqualTo, DateFrom);
dtFilter.MemberType = typeof(DateTime);
_filterDescriptior.FilterDescriptors.Add(dtFilter);


So my question is, when using XmlDataProvider, is there anyway to convert data to a native time (DateTime in my case).

Thanks,
Yury
Yury
Top achievements
Rank 1
 answered on 05 Nov 2010
1 answer
180 views
Hi,
   Here is the what i would like to achieve.
   I have special dates collection with fields date and description. I would like to highlight those dates with Red background in the Calendar control and in the Tooltip or Mouseover I would like to display Order details for that date in the user control.
    Is this possible ? My preference is to write code in VB.Net than XAML
   I tried to search here couldnt find anything that would meet my criteria.

Thank you
Kaloyan
Telerik team
 answered on 04 Nov 2010
Narrow your results
Selected tags
Tags
+? more
Top users last month
Jay
Top achievements
Rank 3
Iron
Iron
Iron
Benjamin
Top achievements
Rank 3
Bronze
Iron
Veteran
Radek
Top achievements
Rank 2
Iron
Iron
Iron
Bohdan
Top achievements
Rank 2
Iron
Iron
Richard
Top achievements
Rank 4
Bronze
Bronze
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Jay
Top achievements
Rank 3
Iron
Iron
Iron
Benjamin
Top achievements
Rank 3
Bronze
Iron
Veteran
Radek
Top achievements
Rank 2
Iron
Iron
Iron
Bohdan
Top achievements
Rank 2
Iron
Iron
Richard
Top achievements
Rank 4
Bronze
Bronze
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?