Drawing line on a click on ZedGraph Pane

https://stackoverflow.com/questions/12422398/drawing-line-on-a-click-on-zedgraph-pane

public Form1()
    {
        InitializeComponent();
    }        

    PointPairList userClickrList = new PointPairList();
    LineItem userClickCurve = new LineItem("userClickCurve");

    private void zedGraphControl1_MouseClick(object sender, MouseEventArgs e)
    {
        // Create an instance of Graph Pane
        GraphPane myPane = zedGraphControl1.GraphPane;

        // x & y variables to store the axis values
        double xVal;
        double yVal;

        // Clear the previous values if any
        userClickrList.Clear();

        myPane.Legend.IsVisible = false;

        // Use the current mouse locations to get the corresponding 
        // X & Y CO-Ordinates
        myPane.ReverseTransform(e.Location, out xVal, out yVal);

        // Create a list using the above x & y values
        userClickrList.Add(xVal, myPane.YAxis.Scale.Max);
        userClickrList.Add(xVal, myPane.YAxis.Scale.Min);

        // Add a curve
        userClickCurve = myPane.AddCurve(" ", userClickrList, Color.Red, SymbolType.None);

        zedGraphControl1.Refresh();
    }

enter image description here

you just have to change the userClickList to draw horizontal line.

转载于:https://www.cnblogs.com/zeroone/p/9732185.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值