chart控件的Annotation为什么没有能显示出来

 我来答
就烦条0o
2016-07-30 · 知道合伙人软件行家
就烦条0o
知道合伙人软件行家
采纳数:33315 获赞数:46492
从事多年系统运维,喜欢编写各种小程序和脚本。

向TA提问 私信TA
展开全部
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Windows.Forms.DataVisualization.Charting;

namespace 人体节律
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void Form1_Load(object sender, EventArgs e)
{
三曲线(生日.Value);
}

private void 三曲线(DateTime 生日)
{
//曲线显示.ChartAreas.Clear();
//曲线显示.ChartAreas.Add("Default");
曲线显示.ChartAreas["Default"].AxisX.LabelStyle.Interval = 1;
//曲线显示.ChartAreas["租睁Default"].AxisX.LabelStyle.Format = "##.##";
曲线显示.ChartAreas["Default"].AxisX.MajorGrid.Interval = 1;
曲线显示.ChartAreas["Default"].AxisY.MajorGrid.Interval = 0.1;//Y轴间隔
曲线显示.ChartAreas["Default"].AxisY.LabelStyle.Interval = 0.1;//Y轴标注

//曲线显示.ChartAreas["Default"弊镇岁].Area3DStyle.Enable3D = true;
//曲线显示.ChartAreas["Default"].AxisX.MinorGrid.Interval = 1;
//曲线显示.ChartAreas["Default"].AxisX.MinorTickMark.Interval = 1;
//曲线显示.ChartAreas["Default"].AxisX.MajorTickMark.Interval = 1;
//曲线显示.ChartAreas["Default"].AxisY.MinorGrid.Interval = 0.1;
//------------------------------------

DateTime 当前日期 = System.DateTime.Now;
DateTime 假定日期 = Convert.ToDateTime("1900-1-1");
if (生日 != 当前日期) { 假定日期 = 生日; }
System.TimeSpan 日差值 = 当前旅纤日期 - 假定日期;
int 间隔 = 日差值.Days, 智力 = 间隔 % 33, 情绪 = 间隔 % 28, 体力 = 间隔 % 23; double 均值 = (智力 + 情绪 + 体力) / 3;
曲线显示.Series["智力"].Points.Clear(); 曲线显示.Series["情绪"].Points.Clear(); 曲线显示.Series["体力"].Points.Clear(); 曲线显示.Series["均值"].Points.Clear();
for (double t = 0; t <= 2 * 16.5; t++)//画多长的曲线 t <= 数值可调整如等于33则显示完整的33一个正弦波形
{
double ch1 = Math.Sin((t + 智力) * 2 * Math.PI / 33);//2*Math.PI*r一个圆周按R的步进增长乘以正弦函数得到点坐标形成以时间为X轴展开的正弦波形/一个周期画多少个点(周期)
曲线显示.Series["智力"].Points.AddXY(t, ch1);
double ch2 = Math.Sin((t + 情绪) * 2 * Math.PI / 28);
曲线显示.Series["情绪"].Points.AddXY(t, ch2);
double ch3 = Math.Sin((t + 体力) * 2 * Math.PI / 23);
曲线显示.Series["体力"].Points.AddXY(t, ch3);
double ch4 = 0.1 * Math.Sin((t + 均值) * 2 * Math.PI / 23);
曲线显示.Series["均值"].Points.AddXY(t, ch4);
}
}
private void Form1_Paint(object sender, PaintEventArgs e)
{
画网格();
}
private void 画网格()
{
int 小时 = DateTime.Now.Hour;
int 秒 = DateTime.Now.Second;
int 分钟 = DateTime.Now.Minute;
//Graphics 实例 = 曲线显示.CreateGraphics();
Graphics 实例 = this.CreateGraphics();
//实例.Clear(Color.White);
Pen 线条 = new Pen(Color.Green, 1);
Pen 线条1 = new Pen(Color.Orange, 1);
for (int 线 = 10; 线 < 210; 线 = 线 + 10)
{
实例.DrawLine(线条, new Point(线 + 30, 10), new Point(线 + 30, 200));//竖线需X坐标=同
实例.DrawLine(线条1, new Point(40, 线), new Point(230, 线));//横线需Y坐标=同
}

string[] 标注 = { "100", "90", "80", "70", "60", "50", "40", "30", "20", "10", "0", "-10", "-20", "-30", "-40", "-50", "-60", "-70", "-80", "-90", "-100" };
int y = 0; Font font = new System.Drawing.Font("Arial", 9, FontStyle.Regular);

for (int i = 0; i < 21; i++)
{ 实例.DrawString(标注[i].ToString(), font, Brushes.Red, 0, y); y = y + 10; }

PointF[] 弦线值 = new PointF[200], 弦线值1 = new PointF[180];

for (int i = 0; i < 弦线值.Length; i++)
{
弦线值[i].X = 40 + i;//起始位置
弦线值[i].Y = 220 / 2 * (1 - (float)0.8 * (float)Math.Sin(i * 2 * Math.PI / 33));
}// 轴位置 幅度
for (int i = 0; i < 弦线值1.Length; i++)
{
弦线值1[i].X = 40 + i;//起始位置
弦线值1[i].Y = 220 / 2 * (1 - (float)0.8 * (float)Math.Sin(i * 2 * Math.PI / 28));
}
实例.DrawLines(new Pen(SystemColors.WindowText), 弦线值);
实例.DrawLines(new Pen(SystemColors.WindowText), 弦线值1);

}

private void 生日_ValueChanged(object sender, EventArgs e)
{
三曲线(生日.Value);
}

private void button1_Click(object sender, EventArgs e)
{
//三曲线(生日.Value);
}

private void 曲线显示_Paint(object sender, PaintEventArgs e)
{
//三曲线(生日.Value);
}

}
}
[csharp] view plain copy print?
//
// 曲线显示
//
this.
曲线显示.Anchor = ((System.Windows.Forms.AnchorStyles)
((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
chartArea1.AxisX.IsMarginVisible = false;
chartArea1.AxisX.ScaleBreakStyle.MaxNumberOfBreaks = 1;
chartArea1.AxisX.ScaleBreakStyle.Spacing = 1D;
chartArea1.AxisY.IsMarginVisible = false;
chartArea1.IsSameFontSizeForAllAxes = true;
chartArea1.Name = "Default";
this.曲线显示.ChartAreas.Add(chartArea1);
legend1.Name = "Legend1";
this.曲线显示.Legends.Add(legend1);
this.曲线显示.Location = new System.Drawing.Point(2, 3);
this.曲线显示.Name = "曲线显示";
series1.ChartArea = "Default";
series1.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Spline;
series1.IsXValueIndexed = true;
series1.Legend = "Legend1";
series1.Name = "智力";
series2.ChartArea = "Default";
series2.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Spline;
series2.IsXValueIndexed = true;
series2.Legend = "Legend1";
series2.Name = "情绪";
series3.ChartArea = "Default";
series3.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Spline;
series3.IsXValueIndexed = true;
series3.Legend = "Legend1";
series3.MarkerSize = 1;
series3.Name = "体力";
series4.ChartArea = "Default";
series4.ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Spline;
series4.IsXValueIndexed = true;
series4.Legend = "Legend1";
series4.Name = "均值";
this.曲线显示.Series.Add(series1);
this.曲线显示.Series.Add(series2);
this.曲线显示.Series.Add(series3);
this.曲线显示.Series.Add(series4);
this.曲线显示.Size = new System.Drawing.Size(780, 186);
this.曲线显示.TabIndex = 0;
this.曲线显示.Text = "曲线";
this.曲线显示.Paint += new System.Windows.Forms.PaintEventHandler(this.曲线显示_Paint);
骑驴赶猪hot
2016-07-30 · TA获得超过804个赞
知道小有建树答主
回答量:1060
采纳率:0%
帮助的人:759万
展开全部
是神汪猜没有装完吧,总游型共是三个安装文件,MSChart、MSChart_VisualStudioAddOn、MSChartLP_chs,你不会是没有装第二个吧?陵宴
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式