Visual Studio的制图帮助 [英] Charting help with visual studio

查看:103
本文介绍了Visual Studio的制图帮助的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在将公司目标"放入柱形图时遇到一些问题.我将其作为折线图进行处理,但是折线需要向左延伸更多,向右延伸更多.我尝试将x设置为柱形图开始之前的位置,但这无济于事,它仍然不在y轴上开始,并将所有信息移开.这就是我得到的:图片1

这就是我要的想法:图片2

我意识到我可能无法在那儿实现个人目标,因为这是一个重点,但是如果有人有一个主意...我会全力以赴...除了带有公司和个人目标的3D柱形图在前两个系列的后面.虽然已经有了,但是我不想要它的外观.

可以跨越那条线,但是它弄乱了我的专栏x轴标题.有什么办法解决吗?

代码:

I''m having some problems putting a "company goal" on my column chart. I am doing it as a line graph, but the line needs to extend more left, and more right. I''ve tried setting the x to before where my column chart starts but that doesnt help, it still doesnt start on y axis and and shifts all my info over. this is what i''m getting : Image 1

and this is sort of the idea i''m going for : Image 2

i realize that i probably wont be able to get individual goals on there because it''s one point, but if someone has an idea...i''m all ears...other than 3d column chart with company and individual goals behind the first 2 series..already though of that, but its not the look i''m going for.

got the line to go across, but its messing with my column x axis titles. Any way to fix?

Code:

Chart1.Series.Add("currmonth");
Chart1.Series["currmonth"].ChartType = SeriesChartType.Column;
Chart1.Series["currmonth"].SmartLabelStyle.Enabled = true;
Chart1.Series.Add("prevmonth");
Chart1.Series["prevmonth"].ChartType = SeriesChartType.Column;
Chart1.Series["prevmonth"].SmartLabelStyle.Enabled = true;
Chart1.Series.Add("compgoal");
Chart1.Series["compgoal"].ChartType = SeriesChartType.Line;

Chart1.ChartAreas[0].AxisX.Minimum = 0;
Chart1.ChartAreas[0].AxisX.Maximum = 5;
DataPoint dp3 = new DataPoint();
dp3.SetValueXY(0, 115);
dp3.BorderWidth = 3;
Chart1.Series["compgoal"].Points.Add(dp3);
DataPoint dp4 = new DataPoint();
dp4.SetValueXY(5, 115);
dp4.BorderWidth = 3;
Chart1.Series["compgoal"].Points.Add(dp4);

while (x < 4)
{
    /*DataPoint dp3 = new DataPoint();
    //dp3.XValue = x;
    dp3.YValues = new double[] { Convert.ToDouble(115) };
    dp3.BorderWidth = 3;
    Chart1.Series["compgoal"].Points.Add(dp3);*/
    //---------------------------------------------------------------------------
    DataPoint dp = new DataPoint();
    dp.AxisLabel = username[x];
    //dp.XValue = x+1;
    dp.YValues = new double[] { Convert.ToDouble(average[x]) };
    dp.Label = average[x].ToString() + " || " + count[x];
    dp.LabelForeColor = Color.DarkGreen;
    //dp.Color = Color.CornflowerBlue;
    dp.Font = new System.Drawing.Font(FontFamily.GenericSerif, 10, FontStyle.Bold);
    Chart1.Series["currmonth"].Points.Add(dp);
    //-----------------------------------
    DataPoint dp2 = new DataPoint();
    dp2.AxisLabel = username2[x];
    //dp.XValue = x+1;
    dp2.YValues = new double[] { Convert.ToDouble(average2[x]) };
    dp2.Label = average2[x].ToString() + " || " + count2[x];
    dp2.LabelForeColor = Color.Brown;
    //dp2.Color = Color.MediumSeaGreen;
    //dp2.BorderColor = Color.DarkGreen;
    dp2.Font = new System.Drawing.Font(FontFamily.GenericSerif, 10, FontStyle.Bold);
    Chart1.Series["prevmonth"].Points.Add(dp2);

    x++;
}
//new data point for company goal


Chart1.Palette = ChartColorPalette.BrightPastel;
//Chart1.Palette = ChartColorPalette.Pastel;
Chart1.Titles[0].Text = "Appraisal Order Matrix";
Chart1.ChartAreas[0].AxisX.Title = ddlMonths.SelectedValue;
Chart1.ChartAreas[0].AxisY.Title = "$";
Chart1.Legends.Add(new Legend() { Name = "Legend" });
Chart1.Legends[0].Docking = Docking.Bottom;
Chart1.Series["currmonth"].Name = "Current Month";
Chart1.Series["prevmonth"].Name = "Previous Month";
Chart1.Series["compgoal"].Name = "Company Goal";


推荐答案

"; Chart1.Legends.Add( Legend(){名称= " }); Chart1.Legends [ 0 ].Docking = Docking.Bottom; Chart1.Series [" ].Name = " 当前月份"; Chart1.Series [" ].Name = " 上个月"; Chart1.Series [" ].Name = " 公司目标";
"; Chart1.Legends.Add(new Legend() { Name = "Legend" }); Chart1.Legends[0].Docking = Docking.Bottom; Chart1.Series["currmonth"].Name = "Current Month"; Chart1.Series["prevmonth"].Name = "Previous Month"; Chart1.Series["compgoal"].Name = "Company Goal";


感谢您的帮助!


any help is appreciated!


这篇关于Visual Studio的制图帮助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆