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

Problem with HorizontalStackBar chart

3 Answers 44 Views
Chart
This is a migrated thread and some comments may be shown as answers.
luke
Top achievements
Rank 1
luke asked on 31 May 2011, 11:36 AM
Hi,

Im trying creating achive result with chart like on supply screen. ItemsSource is dynamic list, so im creating it imperative way in code

private void BuildChart()
        {
  
            RadChart1.SeriesMappings.Clear();
            SeriesMapping map = new SeriesMapping();
            var groupSett = new GroupingSettings() { StackGroupFieldName = "TimeType" };
            groupSett.GroupDescriptors.Add(new ChartGroupDescriptor() { Member = "TimeType" });
            map.GroupingSettings = groupSett;
            map.SeriesDefinition = new HorizontalStackedBarSeriesDefinition() ;
            ItemMapping imap = new ItemMapping();
            imap.DataPointMember = DataPointMember.XCategory;
            imap.FieldName = "UserName";
            map.ItemMappings.Add(imap);
  
            imap = new ItemMapping();
            imap.DataPointMember = DataPointMember.YValue;
            imap.FieldName = "Time";//RealTime
  
            map.ItemMappings.Add(imap);
                RadChart1.SeriesMappings.Add(map);
}
  
public List<UserRecords> GetData()
{
foreach(var item in e.Result)
{
                    UserRecord rec = new UserRecord();
                    rec.StandardTime = item.RealTime.Ticks ;
                    rec.TimeType= "RealTime";
                    rec.UserName= item.UserName;
                    userrecs.Add(rec);
  
                    UserRecord rec2 = new UserRecord();
                    rec2.StandardTime = item.StandardTime.Ticks ;
                    rec2.TimeType= "StdTime";
                    rec2.UserName= item.UserName;
  
  
                    userrecs.Add(rec2);
}
return userrecs;
}
  
class UserRecords
{                public string TimeType{ get; set; }
            public string UserName{ get; set; }
            public double Time { get; set; }
            public int TaskNumber{ get; set; }
}
  
//initializing chart
RadChart1.ItemsSource = GetData();

At screen which i applied each color is one task. It's grouped for each user. Real times of task, and planned times.
How can i achive result like on screen?

thanks in advance for help.

ps. I have problem with uploading screen files to this thread, so im attached in on outer server
http://imageshack.us/f/232/telerikchart.jpg/

3 Answers, 1 is accepted

Sort by
0
Nikolay
Telerik team
answered on 02 Jun 2011, 08:09 AM
Hello luke,

Could you, please, provide a bit more details on your scenario. Is the problem you're facing that you are unable to create the dual layer X-Axis label, like in the image you've linked, or something with the HorizontalStackedBarSeries itself? If it is the former, unfortunately the current version of RadChart does not support having two layers of X-axis labels.

In case the problem you've encountered is different, then could you, please, open a support ticket and send us a sample runnable application, which demonstrates the issue, so that we could provide further support.

Kind regards,
Nikolay
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
luke
Top achievements
Rank 1
answered on 02 Jun 2011, 01:38 PM
Hi,
thanks for respond.

No, i dont meant to make dual layer. Maybe this screen explain more clearly what effect i would like to have.

There is some users which working on some tasks.(lets yellow color in down part of my screen mean this task). The task has planned time to work on it- Bottom of each "group". Worker worked on  tasks(on screen 3 task). On top of this i would like to see "bar series"/"bar with real time of doing task. In my user grouping their bars work ok. But i can't  "divide" bars to represent task separetly, instead i have solid color block containing all tasks.
For my case important is also that  tasks have same color block( i can easly compare planned time and real time-on screen blue blocks is same task,oragne and yellow as well)





Ps. Is it possible to reserve some color ("red") to represent not planned task in my bar? I think my contract would look like this:

little explaination:
TimeType-im using to group to right bar-real time or planned time(bottom or top bar of each user ),"RealTime","StdTime"
Time - real/planned time. TimeType field "branch" it to right bar

class UserRecords
{                public string TimeType{ get; set; }//real std(planned)
            public string UserName{ get; set; }
            public double Time { get; set; }//time spent
            public int TaskNumber{ get; set; }//task number
                public bool IsPlanned{get; set;}/? red color if not...
}


im building chart way i posted in first post.

Screen:
http://imageshack.us/f/825/desirechart.png/
0
Nikolay
Telerik team
answered on 07 Jun 2011, 09:15 AM
Hello luke,

In order to stack the series above each other, you would need to create 2 stacks, with 3 bars in each stack, similarly to our StackedBar demo example. The bars can have the same color by setting PaletteBrushes in the following manner :
<telerik:RadChart x:Name="RadChart1" PaletteBrushesRepeat="True">
    <telerik:RadChart.PaletteBrushes>
        <SolidColorBrush Color="Yellow" />
        <SolidColorBrush Color="Orange" />
        <SolidColorBrush Color="Blue" />
    </telerik:RadChart.PaletteBrushes>
</telerik:RadChart>

As for the not planned tasks, you may add another bar in each stack and add another color ( red ) in the brushes collection.

Generally it is not possible to bind DateTime values to the numeric axis ( axis X in HorizontalStackedBar scenario ) out of the box, however, you may add custom strings, representing the time periods. Here is a snippet demonstrating how you can achieve this :
private void RadChart_DataBound(object sender, ChartDataBoundEventArgs e)
        {
            RadChart chart = sender as RadChart;
  
            foreach (TickPoint tick in chart.DefaultView.ChartArea.AxisX.TickPoints)
            {
                tick.Label = [custom_strings_collection_here];
            }
        }

Hope this helps.

Regards,
Nikolay
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
Chart
Asked by
luke
Top achievements
Rank 1
Answers by
Nikolay
Telerik team
luke
Top achievements
Rank 1
Share this question
or