{"@odata.context":"https://analytics.dev.azure.com/Org/Project/_odata/v3.0/$metadata#WorkItems(WorkItemType,State,Count)","value":[{"@odata.id":null,"State":"Approved","WorkItemType":"Bug","Count":2},{"@odata.id":null,"State":"Committed","WorkItemType":"Bug","Count":1},{"@odata.id":null,"State":"Done","WorkItemType":"Bug","Count":217},{"@odata.id":null,"State":"New","WorkItemType":"Bug","Count":2},{"@odata.id":null,"State":"Removed","WorkItemType":"Bug","Count":6},{"@odata.id":null,"State":"Done","WorkItemType":"Epic","Count":428},{"@odata.id":null,"State":"In Progress","WorkItemType":"Epic","Count":183},{"@odata.id":null,"State":"New","WorkItemType":"Epic","Count":104},{"@odata.id":null,"State":"Removed","WorkItemType":"Epic","Count":3},{"@odata.id":null,"State":"Done","WorkItemType":"Feature","Count":900},{"@odata.id":null,"State":"In Progress","WorkItemType":"Feature","Count":443},{"@odata.id":null,"State":"New","WorkItemType":"Feature","Count":747},{"@odata.id":null,"State":"Removed","WorkItemType":"Feature","Count":5},{"@odata.id":null,"State":"Closed","WorkItemType":"Impediment","Count":8},{"@odata.id":null,"State":"Open","WorkItemType":"Impediment","Count":21},{"@odata.id":null,"State":"Approved","WorkItemType":"Product Backlog Item","Count":148},{"@odata.id":null,"State":"Committed","WorkItemType":"Product Backlog Item","Count":343},{"@odata.id":null,"State":"Done","WorkItemType":"Product Backlog Item","Count":10811},{"@odata.id":null,"State":"New","WorkItemType":"Product Backlog Item","Count":440},{"@odata.id":null,"State":"Removed","WorkItemType":"Product Backlog Item","Count":108},{"@odata.id":null,"State":"Active","WorkItemType":"Shared Parameter","Count":1},{"@odata.id":null,"State":"Closed","WorkItemType":"Shared Steps","Count":1},{"@odata.id":null,"State":"Done","WorkItemType":"Task","Count":12656},{"@odata.id":null,"State":"In Progress","WorkItemType":"Task","Count":151},{"@odata.id":null,"State":"Removed","WorkItemType":"Task","Count":55},{"@odata.id":null,"State":"To Do","WorkItemType":"Task","Count":222},{"@odata.id":null,"State":"Closed","WorkItemType":"Test Case","Count":3},{"@odata.id":null,"State":"Design","WorkItemType":"Test Case","Count":470},{"@odata.id":null,"State":"Ready","WorkItemType":"Test Case","Count":6},{"@odata.id":null,"State":"Active","WorkItemType":"Test Plan","Count":12},{"@odata.id":null,"State":"Completed","WorkItemType":"Test Suite","Count":1},{"@odata.id":null,"State":"In Progress","WorkItemType":"Test Suite","Count":60}]}
And I need to do alot of manual data structuring. Also instead of Images in the small circles I want to show the work item type (from Json).
Please advise what will be the best approach. As this is the final screen and we want to release it.
|
…
var response = await _client.GetAsync("https://analytics.dev.azure.com/slb-it/digital-cells-sso-
dna/_odata/v3.0//WorkItems? &$apply = groupby((WorkItemType, State),
aggregate($count as Count))");
if (response.IsSuccessStatusCode)
{
var content = await response.Content.ReadAsStringAsync();
var dashboardValue = DashboardModel.FromJson(content);
foreach (var item in dashboardValue)
{
foreach (var tem in item.Value)
{
DoughnutSeriesData = new ObservableCollection<MultipleCircleModel>
{
new MultipleCircleModel(tem.WorkItemType, tem.Count,"Car.png"),
};//creating new instance always here for DoughnutSeriesData not clear
}
}
return DoughnutSeriesData;
}
… |
|
private readonly HttpClient _client = new HttpClient();
protected override async void OnAppearing()
{
string content = await _client.GetStringAsync(Url);
var json_Datas = JsonConvert.DeserializeObject<ObservableCollection<Model>>(content);
viewModel.Data = json_Datas;
myChart.BindingContext = viewModel;
base.OnAppearing();
} |
|
<chart:SfChart.Series>
<chart:ColumnSeries ItemsSource="{Binding Data}" XBindingPath="CustomerID" YBindingPath="OrderID">
</chart:ColumnSeries>
</chart:SfChart.Series> |
|
…
<chart:ChartLegend.ItemTemplate>
<DataTemplate>
<StackLayout Orientation="Horizontal" x:Name="root" >
….
<StackLayout HeightRequest="100" WidthRequest="100">
<chart:SfChart VerticalOptions="FillAndExpand"
HorizontalOptions="FillAndExpand">
<chart:SfChart.Series>
<chart:DoughnutSeries StartAngle="-90"
CapStyle="BothCurve" EndAngle="270" MaximumValue="100"
CircularCoefficient="1" IsStackedDoughnut="true" x:Name="series"
ItemsSource="{Binding Converter={StaticResource
indexToItemSourceConverter}}"
XBindingPath="WorkItemType" YBindingPath="Count"
Color="{Binding IconColor}" EnableAnimation="True">
<chart:DoughnutSeries.CenterView>
<Grid>
<Grid.RowDefinitions>
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
</Grid.RowDefinitions>
<Label x:Name="workItem" Grid.Row="0" Text="{Binding
BindingContext.DataPoint.WorkItemType}"
VerticalTextAlignment="Center"
HorizontalTextAlignment="Center"
HorizontalOptions="Center" VerticalOptions="Center"/>
<Label x:Name="count" Grid.Row="1" Text="{Binding
BindingContext.DataPoint.Count}"
VerticalTextAlignment="Center"
HorizontalTextAlignment="Center"
HorizontalOptions="Center"
VerticalOptions="Center"/>
</Grid>
</chart:DoughnutSeries.CenterView>
</chart:DoughnutSeries>
</chart:SfChart.Series>
</chart:SfChart>
</StackLayout>
</StackLayout>
</DataTemplate>
</chart:ChartLegend.ItemTemplate>
… |
{"@odata.context":"https://analytics.dev.azure.com/slb-it/digital-cells-sso-dna/_odata/v3.0/$metadata#WorkItems(WorkItemType,State,Count)","value":[{"@odata.id":null,"State":"Approved","WorkItemType":"Bug","Count":1},{"@odata.id":null,"State":"Committed","WorkItemType":"Bug","Count":1},{"@odata.id":null,"State":"Done","WorkItemType":"Bug","Count":220},{"@odata.id":null,"State":"New","WorkItemType":"Bug","Count":2},{"@odata.id":null,"State":"Removed","WorkItemType":"Bug","Count":7},{"@odata.id":null,"State":"Done","WorkItemType":"Epic","Count":438},{"@odata.id":null,"State":"In Progress","WorkItemType":"Epic","Count":179},{"@odata.id":null,"State":"New","WorkItemType":"Epic","Count":108},{"@odata.id":null,"State":"Removed","WorkItemType":"Epic","Count":3},{"@odata.id":null,"State":"Done","WorkItemType":"Feature","Count":919},{"@odata.id":null,"State":"In Progress","WorkItemType":"Feature","Count":448},{"@odata.id":null,"State":"New","WorkItemType":"Feature","Count":769},{"@odata.id":null,"State":"Removed","WorkItemType":"Feature","Count":5},{"@odata.id":null,"State":"Closed","WorkItemType":"Impediment","Count":10},{"@odata.id":null,"State":"Open","WorkItemType":"Impediment","Count":21},{"@odata.id":null,"State":"Approved","WorkItemType":"Product Backlog Item","Count":150},{"@odata.id":null,"State":"Committed","WorkItemType":"Product Backlog Item","Count":238},{"@odata.id":null,"State":"Done","WorkItemType":"Product Backlog Item","Count":11158},{"@odata.id":null,"State":"New","WorkItemType":"Product Backlog Item","Count":445},{"@odata.id":null,"State":"Removed","WorkItemType":"Product Backlog Item","Count":118},{"@odata.id":null,"State":"Active","WorkItemType":"Shared Parameter","Count":1},{"@odata.id":null,"State":"Closed","WorkItemType":"Shared Steps","Count":1},{"@odata.id":null,"State":"Done","WorkItemType":"Task","Count":13032},{"@odata.id":null,"State":"In Progress","WorkItemType":"Task","Count":124},{"@odata.id":null,"State":"Removed","WorkItemType":"Task","Count":56},{"@odata.id":null,"State":"To Do","WorkItemType":"Task","Count":198},{"@odata.id":null,"State":"Closed","WorkItemType":"Test Case","Count":3},{"@odata.id":null,"State":"Design","WorkItemType":"Test Case","Count":472},{"@odata.id":null,"State":"Ready","WorkItemType":"Test Case","Count":6},{"@odata.id":null,"State":"Active","WorkItemType":"Test Plan","Count":12},{"@odata.id":null,"State":"Completed","WorkItemType":"Test Suite","Count":1},{"@odata.id":null,"State":"In Progress","WorkItemType":"Test Suite","Count":60}]}As provided in my code earlier, i was getting this response.
In the sample they are too many extra classes and i am going through the whole code and checking what there. It will be really appreciated that the sample provided only has the required classes.
My understanding was that the JSON data should be parsed in a specific structure in order for the Chart to accept it. thats why I was converting it.
Please provide a clean sample so its a bit easier to understand and I can try to implement it. Thank you, your support is highly appreciated.
And there is an extra chart added on top of multiple circles. Thats not our requirement. :)
I am trying here to make sure of MVVM aswell. Kindly update me. I am gonna try from myside too.
|
<StackLayout x:Name="stack">
. . . . .
<chart:SfChart.Series>
<chart:DoughnutSeries StartAngle="-90"
CapStyle="BothCurve"
EndAngle="270"
MaximumValue="100"
CircularCoefficient="0.9"
IsStackedDoughnut="true"
x:Name="doughnutSeries"
ItemsSource="{Binding PriceChartDictonaryModel}"
XBindingPath="Subject"
YBindingPath="Percentage"
LegendIcon="Circle"
Spacing="0.4"
EnableAnimation="True">
<chart:DoughnutSeries.CenterView>
<Image Source="Person.png"
HorizontalOptions="Center"
VerticalOptions="Center">
</Image>
</chart:DoughnutSeries.CenterView>
</chart:DoughnutSeries>
</chart:SfChart.Series>
</chart:SfChart> |
|
public class Model
{
public string Subject { get; set; }
public double Percentage { get; set; }
public Model(string subject, double Totalcompleted_hour, double Required_hour)
{
Subject = subject;
Percentage = ( Required_hour/ Totalcompleted_hour) *100;
}
} |
|
public class ViewModel
{
public ObservableCollection<Model> PriceChartDictonaryModel { get; set; }
public ViewModel()
{
PriceChartDictonaryModel = new ObservableCollection<Model>();
PriceChartDictonaryModel.Add(new Model("Mathematics", 10, 5));
PriceChartDictonaryModel.Add(new Model("Science", 8, 3));
PriceChartDictonaryModel.Add(new Model("English", 6, 2));
PriceChartDictonaryModel.Add(new Model("Arts", 4, 4));
}
} |
|
<chart:SfChart.Legend>
<chart:ChartLegend
DockPosition="{OnPlatform UWP='Right', WPF= 'Right', Default= 'Bottom'}"
Margin="{OnPlatform UWP='200,0,200,0'}"
OverflowMode="{OnPlatform UWP='Scroll', Default='Wrap'}">
</chart:ChartLegend>
</chart:SfChart.Legend>
. . .
<chart:SfChart.Series>
<chart:DoughnutSeries Spacing="{OnPlatform UWP='0.5'}"
. . . />
|