Radar.razor 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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. var data = await ChartService.GetRadarDataAsync();
  60. await _chart.ChangeData(data);
  61. }
  62. }