PieChart.razor.cs 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. using AntDesign.Charts;
  2. using Microsoft.AspNetCore.Components;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using System.Threading.Tasks;
  7. using wispro.sp.web.Services;
  8. namespace wispro.sp.web.Pages.Report
  9. {
  10. public partial class PieChart
  11. {
  12. private AntDesign.Charts.IChartComponent chart;
  13. private PieConfig config4 = new PieConfig
  14. {
  15. ForceFit = true,
  16. Title = new Title
  17. {
  18. Visible = true,
  19. Text = "Pie Chart-Graphic Tab Spider Layout",
  20. AlignTo= "left"
  21. },
  22. Description = new Description
  23. {
  24. Visible = false,
  25. Text = "When the type of the pie chart label is set to spider, the labels are divided into two groups, and they are displayed in alignment by pulling lines on both sides of the chart. Generally speaking, the labels of the spider layout are less likely to block each other."
  26. },
  27. Radius = 0.8,
  28. AngleField = "value",
  29. ColorField = "ColumnA",
  30. Label = new PieLabelConfig
  31. {
  32. Visible = true,
  33. Type = "spider"
  34. }
  35. };
  36. private share.ChartDatas Datas=new share.ChartDatas() {
  37. Title ="初始化标题",
  38. Datas = new List<share.ChartData>() {
  39. new share.ChartData(){ ColumnA ="A",value =1}
  40. },
  41. ATitle =""
  42. };
  43. [Inject] ReportService reportService { get; set; }
  44. [Obsolete]
  45. protected async override Task OnInitializedAsync()
  46. {
  47. Datas = await reportService.GetAppealReportData(1,DateTime.Parse("2022-02-01"),null,null);
  48. if (Datas != null)
  49. {
  50. config4.Title.Text = Datas.Title;
  51. config4.XField = Datas.ATitle;
  52. await chart.ChangeData(Datas.Datas);
  53. await chart.UpdateChart(config4);
  54. StateHasChanged();
  55. }
  56. await base.OnInitializedAsync();
  57. }
  58. }
  59. }