Radar.razor 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. @using wispro.sp.web.Services
  2. <AntDesign.Charts.Radar @ref="_chart" TItem="RadarDataItem" Config="_chartConfig"/>
  3. @if (HasLegend)
  4. {
  5. <Row Class="legend">
  6. <AntDesign.Col>
  7. <div class="legendItem">
  8. <p>
  9. <span class="dot" style="background-color: #aaa"></span>
  10. <span></span>
  11. </p>
  12. <h6></h6>
  13. </div>
  14. </AntDesign.Col>
  15. </Row>
  16. }
  17. @inject IChartService ChartService
  18. @code
  19. {
  20. [Parameter]
  21. public bool HasLegend { get; set; } = false;
  22. [Parameter]
  23. public int Height { get; set; } = 343;
  24. private IChartComponent _chart;
  25. private readonly RadarConfig _chartConfig = new RadarConfig
  26. {
  27. Height = 400,
  28. ForceFit = true,
  29. AngleField = "label",
  30. RadiusField = "value",
  31. SeriesField = "name",
  32. RadiusAxis = new ValueAxis
  33. {
  34. Grid = new BaseAxisGrid
  35. {
  36. Line = new BaseAxisGridLine
  37. {
  38. Type = "line"
  39. }
  40. }
  41. },
  42. Area = new RadarViewConfigArea
  43. {
  44. Visible = false
  45. },
  46. Point = new RadarViewConfigPoint
  47. {
  48. Visible = true
  49. },
  50. Legend = new Legend
  51. {
  52. Visible = true,
  53. Position = "bottom-center"
  54. },
  55. };
  56. protected override async System.Threading.Tasks.Task OnInitializedAsync()
  57. {
  58. await base.OnInitializedAsync();
  59. try
  60. {
  61. var data = await ChartService.GetRadarDataAsync();
  62. await _chart.ChangeData(data);
  63. }
  64. catch { }
  65. }
  66. }