123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168 |
- using AntDesign;
- using AntDesign.Charts;
- using Microsoft.AspNetCore.Components;
- using System;
- using System.Collections.Generic;
- using System.Data;
- using System.Linq;
- using System.Text.Json;
- using System.Threading.Tasks;
- using wispro.sp.share;
- using wispro.sp.web.Services;
- namespace wispro.sp.web.Pages.Report
- {
- public partial class AppealTrend
- {
- private int iType = 3;
- private DateTime? start = new DateTime(DateTime.Now.Year, 1, 1);
- private DateTime? end = DateTime.Now;
- internal class TJType
- {
- public string Name { get; set; }
- public int value { get; set; }
- }
- List<TJType> Types = new List<TJType>
- {
- new TJType { value = 3,Name = "申诉人统计" },
- new TJType { value = 4,Name = "申诉类型统计" },
- new TJType { value = 4,Name = "部门申诉统计" },
-
- };
- share.ChartDatas Datas = new share.ChartDatas()
- {
- Title = "初始化标题",
- Datas = new List<share.ChartData>() {
- new share.ChartData(){ type ="部门一", value =1, year="2022-01", CustomerType ="", CustomerYear=""},
- new share.ChartData(){ type ="部门一",value =5, year="2022-02",CustomerType ="", CustomerYear=""},
- new share.ChartData(){ type ="部门二", value =3, year="2022-01", CustomerType ="", CustomerYear=""},
- new share.ChartData(){ type ="部门二",value =4, year="2022-02",CustomerType ="", CustomerYear=""},
- new share.ChartData(){ type ="部门三",value =2.5, year="2022-02",CustomerType ="", CustomerYear=""}
- },
- ATitle = "部门",
- BTitle = "申诉月份"
- };
- LineConfig config = new LineConfig
- {
- Title = new AntDesign.Charts.Title
- {
- Visible = true,
- Text = "带数据点的折线图"
- },
- ForceFit = true,
- Padding = "auto",
- XField = "year",
- YField = "value",
- SeriesField = "type",
-
- Point = new LineViewConfigPoint
- {
- Visible = true
- },
- Label = new Label
- {
- Visible = true,
- Type = "point"
- },
- Legend = new Legend
- {
- Visible = false,
- Position = "bottom",
- },
-
- XAxis = new ValueCatTimeAxis
- {
- Type="time",
- //Visible= true,
- //Label = new BaseAxisLabel()
- //{
- // AutoRotate = true
- //},
- //Title = new BaseAxisTitle()
- //{
- // Text = "绩效月份",
- // AutoRotate = true
- //}
- },
- YAxis = new ValueAxis
- {
- Label = new BaseAxisLabel()
- {
- AutoRotate=true
- },
- Title = new BaseAxisTitle()
- {
- Visible=true,
- Text = "申诉数量"
- }
- }
- };
- [Inject] ReportService reportService { get; set; }
- [Inject] MessageService msgService { get; set; }
- private AntDesign.Charts.IChartComponent chart;
- private void OnTimeRangeChange(DateRangeChangedEventArgs args)
- {
- msgService.Info($"Selected Time: {JsonSerializer.Serialize(args.Dates)}");
- Console.WriteLine($"Selected Time: {JsonSerializer.Serialize(args.Dates)}");
- Console.WriteLine($"Formatted Selected Time: {JsonSerializer.Serialize(args.DateStrings)}");
- if (args.Dates?.Length > 0)
- {
- Console.WriteLine(args.Dates[0]);
- start = args.Dates[0];
- }
- if (args.Dates?.Length > 1)
- {
- Console.WriteLine(args.Dates[1]);
- end = args.Dates[1];
- }
- }
- private bool _noIconLoading;
- private async Task OnButtonClick()
- {
- _noIconLoading = true;
- Datas = await reportService.GetAppealReportData(iType, start, end, null);
- if (Datas != null)
- {
- config.Title.Text = Datas.Title;
- config.XField = Datas.ATitle;
- await chart.ChangeData(Datas.Datas);
- await chart.UpdateChart(config);
- StateHasChanged();
- }
- _noIconLoading = false;
- }
- protected async override Task OnInitializedAsync()
- {
- //Datas = await reportService.GetAppealReportData(iType, DateTime.Parse("2022-01-01"), DateTime.Now, null);
- if (Datas != null)
- {
- config.Title.Text = Datas.Title;
-
- await chart.ChangeData(Datas.Datas);
- await chart.UpdateChart(config);
- StateHasChanged();
- }
- await base.OnInitializedAsync();
- }
-
- }
- }
|