You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

65 lines
2.7 KiB
C#

using AUCMA.STORE.Common;
using AUCMA.STORE.Entity.DAO;
using AUCMA.STORE.Entity.Enums;
using AUCMA.STORE.SqlSugar.serviceImpl;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Windows.Forms.DataVisualization.Charting;
namespace AUCMA.STORE
{
public partial class Chart : Form
{
public String PilerInfo = "";
public LocationArea locationArea = LocationArea.Location_NoCare;
public Chart()
{
InitializeComponent();
this.StartPosition = FormStartPosition.CenterScreen;
}
private void Chart_Load(object sender, EventArgs e)
{
this.chart1.Series[0].Points.Clear();
this.chart1.ChartAreas[0].Area3DStyle.Enable3D = true;
chart1.Series[0].ChartType = SeriesChartType.Pie;
chart1.Legends[0].Enabled = false;//不显示图例
this.chart1.Series["Series1"].Label = "#VALX" + " " + " [ " + "#VAL{D} 个" + " ]" + " " + "#PERCENT{P2}";
//this.chart1.Series["Series1"].LegendText = "#VALX" + " " + " [ " + "#VAL{D} 个" + " ]" + " " + "#PERCENT{P2}";
chart1.Series[0]["DrawingStyle"] = "Cylinder";//设置Series显示的样式 绘图风格为浮雕型
chart1.Series[0].XValueType = ChartValueType.String;
/*chart1.Series[0]["PieLabelStyle"] = "Outside";
chart1.Series[0]["PieLineColor"] = "Black";*///绘制黑色的连线。
//double[] yValues = { 20, 30, 40, 50 };
//string[] xValues = { "绩效办", "行政部", "王牌对王牌", "其他" };
//chart1.Series["Series1"].Points.DataBindXY(xValues, yValues);
BindChartData(locationArea);
}
public async void BindChartData(LocationArea locationArea)
{
Expression<Func<BaseLocationInfo, bool>> exp = s1 => true;
exp = exp.And(s1 => s1.locationArea == locationArea && s1.locationStatus == LocationStatus.InUse && s1.storeCode == ConfigHelper.GetConfig("storeCode") && s1.deleteFlag == DeleteFlag.No);
List<BaseLocationInfo> baseLocationInfos = await new BaseServices<BaseLocationInfo>().Query(exp);
List<string> xData = new List<string>();
List<int> yData = new List<int>();
var info = baseLocationInfos.GroupBy(x => x.materialType);
foreach (var item in info)
{
xData.Add(item.Key);
yData.Add(item.ToList().Count());
}
chart1.Series["Series1"].Points.DataBindXY(xData, yData);
}
}
}