图表问题 [英] Charting Problems

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

问题描述

我在制定"公司目标"方面遇到了一些问题。在我的柱形图上。我这样做是一个折线图,但是这条线需要向左延伸更多,更正确。我已经尝试将x设置为我的柱形图开始之前,但这没有帮助,它仍然没有
从y轴开始并且将我的所有信息转移。这就是我得到的:
我得到的是什么

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 : What i'm getting

这就是我想要的想法:
目标

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

我意识到我可能无法在那里获得个人目标,因为这是一点,但如果有人有想法......我都是耳朵......除了3d前两个系列背后有公司和个人目标的柱形图。尽管如此,但是
它不是我想要的样子。

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.

编辑:得到了这条线过去,但它与我的列X轴标题混乱。有什么方法可以修复吗?

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

代码:

 

        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;

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.YValues = new double[] { Convert.ToDouble(average[x]) }; dp.Label = average[x].ToString() + " || " + count[x]; dp.LabelForeColor = Color.DarkGreen; 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; dp2.YValues = new double[] { Convert.ToDouble(average2[x]) }; dp2.Label = average2[x].ToString() + " || " + count2[x]; dp2.LabelForeColor = Color.Brown; dp2.Font = new System.Drawing.Font(FontFamily.GenericSerif, 10, FontStyle.Bold); Chart1.Series["prevmonth"].Points.Add(dp2); x++; } Chart1.Palette = ChartColorPalette.BrightPastel; 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";

 

any感谢帮助!

推荐答案

你应该做的是使用
StripLine

注释掉将数据点添加到"compgoal"的所有行。系列
(dp3和dp4。)然后将其添加到代码段的末尾:

Comment out all the lines to do with adding data points to the "compgoal" series (dp3 and dp4.) Then add this to the end of your code snippet:


	StripLine sl = new StripLine();
	sl.IntervalOffset = 115; //This is the goal, assuming the Y axis starts from zero.
	sl.Interval = 0; //Will make the stripline only appear once.
	sl.BorderWidth = 3;

	//Optional, will show a "Company Goal" text next to the StripLine. 
	//Having this, you can consider removing the "compgoal" series altogether.
	sl.Text = "Company Goal";

	//Set the stripline color to the same as the series.
	//If you decide to remove the series, just set the color to Color.Red for example, and remove the ApplyPaletteColors call.
	Chart1.ApplyPaletteColors();
	sl.BorderColor = Chart1.Series["Company Goal"].Color;

	//Add the StripLine to the Y axis.
	Chart1.ChartAreas[0].AxisY.StripLines.Add(sl);


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

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