在线急等 winfrom chart控件显示问题

65度 2023-10-20 14:30:45

如下图所示,这个右上角很大一片空白,如果右上角的Legends去掉,又是好的,怎么把这个空白处填满,急等

 

下面是去掉Legends的

 

后台 代码如下:

                    chart1.Series.Clear();
                    chart1.Legends.Clear();
                    int i = 0;
                    foreach (DataRow drW in _dtWh.Rows)
                    {
                        List<string> slistX = new List<string>();
                        List<float> slistY = new List<float>();
                        foreach (DataRow dr in drs)
                        {
                           
                        }
                        string[] x = slistX.ToArray();
                        float[] y = slistY.ToArray();

                        //设置每条线的说明
                        chart1.Legends.Add(new Legend());
                        chart1.Legends[i].Name = drW["cWhName"].ToString();
                        chart1.Legends[i].Docking = Docking.Right;
                        chart1.Legends[i].Alignment = StringAlignment.Near;
                        chart1.Legends[i].LegendStyle = LegendStyle.Column;
                        //chart1.Legends[i].MaximumAutoSize = 10;

                        chart1.Series.Add(new Series());
                        chart1.Series[i].Name = drW["cWhName"].ToString();
                        chart1.Series[i].Label = "#VAL";
                        chart1.Series[i].ToolTip = "#VALX\r#VAL";
                        chart1.Series[i].ChartArea = chart1.ChartAreas[0].Name;
                        chart1.Series[i].ChartType = SeriesChartType.Line;
                        chart1.Series[i].Points.DataBindXY(x, y);
                        //Random rd = new Random();
                        //chart1.Series[i].MarkerBorderColor = Color.FromArgb(rd.Next(255), rd.Next(255), rd.Next(255));
                        if (i == 0)
                            chart1.Series[i].Points[0].Color = Color.Red;  
                        else if (i == 1)
                            chart1.Series[i].Points[0].Color = Color.Blue;
                        else if (i == 2)
                            chart1.Series[i].Points[0].Color = Color.Yellow; 
                        else if (i == 3)
                            chart1.Series[i].Points[0].Color = Color.Orange;  
                        else if (i == 4)
                            chart1.Series[i].Points[0].Color = Color.Violet; 
                        else if (i == 5)
                            chart1.Series[i].Points[0].Color = Color.Green;
                        else if (i == 6)
                            chart1.Series[i].Points[0].Color = Color.Pink; 
                        else if (i == 7)
                            chart1.Series[i].Points[0].Color = Color.Gold; 
                        chart1.Series[i].BorderWidth = 3;
                        chart1.Series[i].MarkerBorderColor = chart1.Series[i].Points[0].Color;
                        chart1.Series[i].MarkerBorderWidth = 3;
                        chart1.Series[i].MarkerColor = Color.Red;
                        chart1.Series[i].MarkerSize = 5;
                        chart1.Series[i].MarkerStyle = MarkerStyle.Circle;

 

...全文
123 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
CSDN-Ada助手 2023-10-20
精选
  • 打赏
  • 举报
回复
您的问题已经帮您同步至问答, 链接: https://ask.csdn.net/questions/8015388, 请您保持关注, 如果回答有帮助解决此问题, 麻烦您动动小手给相关的回答点赞, Ada会在评论区为您更新结题状态
Stealingcoins 2023-10-23
  • 打赏
  • 举报
回复 1

img

img


啥都不用改啊

62,254

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧