Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/316.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何修改图表的背景 如何删除“----系列1”文本(右上角,按钮1附近) 如何制作蓝色的阶梯线,并删除背景线 如何为背景绘制颜色,例如从y=0到y=1的区域,颜色为灰色 如何添加鼠标滚轮事件,以便使用Ctrl+mousewheel放大和缩小图表_C#_Winforms_Charts_Mschart - Fatal编程技术网

C# 如何修改图表的背景 如何删除“----系列1”文本(右上角,按钮1附近) 如何制作蓝色的阶梯线,并删除背景线 如何为背景绘制颜色,例如从y=0到y=1的区域,颜色为灰色 如何添加鼠标滚轮事件,以便使用Ctrl+mousewheel放大和缩小图表

C# 如何修改图表的背景 如何删除“----系列1”文本(右上角,按钮1附近) 如何制作蓝色的阶梯线,并删除背景线 如何为背景绘制颜色,例如从y=0到y=1的区域,颜色为灰色 如何添加鼠标滚轮事件,以便使用Ctrl+mousewheel放大和缩小图表,c#,winforms,charts,mschart,C#,Winforms,Charts,Mschart,谢谢大家! 下面我提供了一些示例代码来回答您的问题。我对3和4的回答是基本示例,您必须计算应用程序中绘制和缩放的正确值 private void button1_Click(object sender, EventArgs e) { setupChart(); } private void setupChart() { // 1. foreach (System.Windows.Forms.DataVisu

谢谢大家!


下面我提供了一些示例代码来回答您的问题。我对3和4的回答是基本示例,您必须计算应用程序中绘制和缩放的正确值

    private void button1_Click(object sender, EventArgs e)
    {
        setupChart();
    }

    private void setupChart()
    {
        // 1.
        foreach (System.Windows.Forms.DataVisualization.Charting.Legend legend in chart1.Legends)
            legend.Enabled = false;

        // 2.
        chart1.Series[0].BorderWidth = 5;
        chart1.ChartAreas[0].AxisX.MajorGrid.Enabled = false;
        chart1.ChartAreas[0].AxisY.MajorGrid.Enabled = false;

        // 3.
        chart1.Paint += new PaintEventHandler(chart1_Paint);

        // 4.
        chart1.MouseWheel += new MouseEventHandler(chart1_MouseWheel);
        //chart must have focus for MouseWheel event to fire
        chart1.Focus();
    }

    private void chart1_Paint(object sender, PaintEventArgs e)
    {
        //basic example of painting

        //determine size of area to paint
        Size areaSize = new Size(50, 50);

        //determine location to paint
        Point point = new Point(100, 450);

        e.Graphics.FillRectangle(new SolidBrush(Color.Gray),
            point.X, point.Y, areaSize.Width, areaSize.Height);
    }

    private void chart1_MouseWheel(object sender, MouseEventArgs e)
    {
        //basic example of zooming in and out
        if (e.Delta > 0)
        {
            chart1.ChartAreas[0].AxisX.ScaleView.Zoom(
                chart1.ChartAreas[0].AxisX.ScaleView.ViewMinimum / 2,
                chart1.ChartAreas[0].AxisX.ScaleView.ViewMaximum / 2);
            chart1.ChartAreas[0].AxisY.ScaleView.Zoom(
                chart1.ChartAreas[0].AxisY.ScaleView.ViewMinimum / 2,
                chart1.ChartAreas[0].AxisY.ScaleView.ViewMaximum / 2);
        }
        else
        {
            if (chart1.ChartAreas[0].AxisX.ScaleView.ViewMaximum <
                chart1.ChartAreas[0].AxisX.Maximum ||
                chart1.ChartAreas[0].AxisX.ScaleView.ViewMinimum >
                chart1.ChartAreas[0].AxisX.Minimum)
            {
                chart1.ChartAreas[0].AxisX.ScaleView.Zoom(
                    chart1.ChartAreas[0].AxisX.ScaleView.ViewMinimum * 2,
                    chart1.ChartAreas[0].AxisX.ScaleView.ViewMaximum * 2);
                chart1.ChartAreas[0].AxisY.ScaleView.Zoom(
                    chart1.ChartAreas[0].AxisY.ScaleView.ViewMinimum * 2,
                    chart1.ChartAreas[0].AxisY.ScaleView.ViewMaximum * 2);
            }
            else
            {
                chart1.ChartAreas[0].AxisX.ScaleView.ZoomReset();
                chart1.ChartAreas[0].AxisY.ScaleView.ZoomReset();
            }
        }
    }
private void按钮1\u单击(对象发送者,事件参数e)
{
setupChart();
}
私有void setupChart()
{
// 1.
foreach(System.Windows.Forms.DataVisualization.Charting.chart1.Legend中的图例System.Windows.Forms.DataVisualization.Charting.Legend)
legend.Enabled=false;
// 2.
图表1.系列[0]。边框宽度=5;
chart1.ChartAreas[0].AxisX.MajorGrid.Enabled=false;
chart1.ChartAreas[0]。AxisY.MajorGrid.Enabled=false;
// 3.
chart1.Paint+=新的PaintEventHandler(chart1_Paint);
// 4.
chart1.MouseWheel+=新的MouseEventHandler(chart1\u MouseWheel);
//图表必须有焦点才能触发鼠标滚轮事件
图1.焦点();
}
私有void chart1_Paint(对象发送器,PaintEventArgs e)
{
//绘画基本范例
//确定要绘制的区域的大小
尺寸面积尺寸=新尺寸(50,50);
//确定要绘制的位置
点=新点(100450);
e、 图形.圆角矩形(新的SolidBrush(颜色.灰色),
点X、点Y、面积大小、宽度、面积大小、高度);
}
专用void chart1_鼠标滚轮(对象发送器,MouseEventArgs e)
{
//放大和缩小的基本示例
如果(e.Delta>0)
{
chart1.ChartAreas[0]。AxisX.ScaleView.Zoom(
chart1.ChartAreas[0]。AxisX.ScaleView.ViewMinimum/2,
chart1.ChartAreas[0].AxisX.ScaleView.ViewMaximum/2);
chart1.ChartAreas[0]。AxisY.ScaleView.Zoom(
chart1.ChartAreas[0]。AxisY.ScaleView.ViewMinimum/2,
chart1.ChartAreas[0].AxisY.ScaleView.ViewMaximum/2);
}
其他的
{
如果(chart1.ChartAreas[0].AxisX.ScaleView.ViewMaximum<
chart1.ChartAreas[0]。AxisX.Maximum||
chart1.ChartAreas[0]。AxisX.ScaleView.ViewMinimum>
图表1.ChartAreas[0]。AxisX.Minimum)
{
chart1.ChartAreas[0]。AxisX.ScaleView.Zoom(
chart1.ChartAreas[0]。AxisX.ScaleView.ViewMinimum*2,
chart1.ChartAreas[0].AxisX.ScaleView.ViewMaximum*2);
chart1.ChartAreas[0]。AxisY.ScaleView.Zoom(
chart1.ChartAreas[0]。AxisY.ScaleView.ViewMinimum*2,
chart1.ChartAreas[0].AxisY.ScaleView.ViewMaximum*2);
}
其他的
{
chart1.ChartAreas[0]。AxisX.ScaleView.ZoomReset();
chart1.ChartAreas[0]。AxisY.ScaleView.ZoomReset();
}
}
}

1)Chart1.Legends.Enabled=“false”2)Series.BorderWidth=“3”chart.mouseweel+=新系统.Windows.Forms.MouseEventHandler(此鼠标滚轮);然后定义moethod