- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我对 ZedGraph 有一些不同的要求。
我想在用户单击 ZedGraph Pane 时在 ZedGraph Pane 上创建曲线。此外,我还在该 Pane 上绘制了其他图表。但我希望每当用户点击 zedGraph 区域时,我们都会得到用户点击的坐标,然后我在点击的坐标上画一条直线。
我已将 MouseCLick 事件 alogn 与 FindNearestObject 方法一起使用,如下所示:
private void zedGraph_RenderedTrack_MouseClick(object sender, EventArgs e)
{
MouseEventArgs xx = (MouseEventArgs)e;
object nearestObject;
int index;
this.zedGraph_RenderedTrack.GraphPane.FindNearestObject(new PointF(xx.X, xx.Y), this.CreateGraphics(), out nearestObject, out index);
if (nearestObject != null)
{
DrawALine(xx.X, Color.Red, true);
}
}
但是使用这个,ZedGraph 搜索一些曲线并找到最近的点,然后绘制线,但我希望在用户点击的地方绘制线。有什么方法可以做到吗?
最佳答案
你可以试试下面的代码,它会为鼠标点击事件绘制一条垂直线。
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();
}
您只需更改 userClickList 即可绘制水平线。
快乐编码......:)
关于c# - 单击 ZedGraph Pane 上的画线,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12422398/
我正在使用 ZedGraph,我想通过按住 Ctrl 缩放到选定区域并用鼠标左键拖动框,而不是用鼠标中键单击和拖动。 默认行为是仅使用鼠标左键缩放并使用鼠标中键平移,但我已经切换了这两个操作。 有没有
我想在图表的右下角添加 Logo 或我的软件名称。我使用了 TextObj,但问题是它的位置通过鼠标滚轮更改图形比例来改变。我应该使用另一个对象,但我不知道它是什么。请帮助我。 最佳答案 这是一个简单
如何在图表中的条形顶部添加一些文本。这是我必须添加栏的代码: var color = ColorTranslator.FromHtml(row.Colour); var barItem = graph
我正在使用 Pane 绘制蜡烛棒 (AddJapaneseCandleStick): XAxis = AxisType.DateAsOrdinal; 到此为止一切正常。 问题: 我想在同一 Pane
我想显示一个不可缩放的ZedGraph控件。如何在ZedGraph中禁用鼠标滚轮缩放功能? 最佳答案 如果您只想禁用鼠标滚轮缩放功能,则可以使用: zedGraphControl.IsEnableWh
我有一个条形图,我想允许用户右键单击特定条形图,选择一些仅影响该条形图的操作(实际上添加一个或任何内容)。使用 ZedGraph 可以实现这种类型的事情吗? 最佳答案 您可以向表单添加鼠标单击事件,并
我有两个关于轴标签的问题: 如何在 Y2 轴上制作一个标签,以在最后一根柱线/烛台的动态价格(y2 值)之后显示突出显示的标签?如this example中的红色标签: XAxis 也可能相同,显示最
我有一些水平直线,希望用户能够垂直拖动。这怎么可能?我认为线选择的最佳参数是线附近固定数量的像素。因此,如果鼠标为 +/- 2 像素,我应该更改鼠标光标并使线条可拖动。我看到 CurveItem 类具
有没有办法修改 ZedGraph 条的宽度?如果是这样,这样做所需的代码是什么?是否有可能使条形图也随着缩放比例缩放?由于当前缩放的工作方式,我有一些条没有显示(x 轴范围很宽,这使得所有条都非常瘦)
我在 ZedGraph 中有一个折线图。数据每秒从串口传来。图表正在运行。但不要在 X 轴上滚动 (scroll) 并在左角压缩。我需要图表从右向左滚动,日期和时间显示在 X 轴上 #region
我使用 ZedGraphs 绘制了一些图表。现在,我有一个选项,用户可以使用不同的复选框绘制一些图表,也可以删除它们。但是,当用户制作这些图表时,我不会缩放图表,因为我不想改变图表的外观。 现在,如果
我已经使用 ZedGraph 一段时间了,但经过数小时的搜索后我感到很沮丧,我找不到如何区分检测缩放事件是“放大”还是“缩小”还是“全部缩小”? 实际上,我正在制作自己的放大和缩小版本,以便在每种情况
如何访问调整图形 Pane 大小时触发的事件? 每次调整大小后,我想固定标题和标签上的文本大小,这样当窗口最大化时它们就不会变大。 最佳答案 你可以订阅ZedGraphControl的resize事件
我正在尝试更改 Zed 图表线上破折号的长度。我希望实线之间有更大的间隙。 我的代码示例 LineItem LineCurve = null LineCurve = ZedGraphControl.G
当我绘制图形、放大和缩小并重新绘制时,图形的位置没有改变。 我希望能够做的是在重绘数据时更改 View 以查看所有图形数据。如果您在重绘之前放大或缩小,这似乎被禁用。 谢谢! 最佳答案 将控件的属性
我试图在我的一个轴(X 轴)上获取持续时间。目前我使用日期轴,虽然这不能有第 0 天。我目前有: 如您所见,我没有我需要的第 0 天,因为第 0 天可能发生了某些事情(好吧,距离开始不到 24 小时。
我使用 ZedGraph 只需单击一下即可绘制来自多个来源的数据。我需要 Y 轴对于每个图始终具有相同的最大值和最小值。我需要它能够在我浏览数据集时看到它们之间的变化。就我而言,在一张图中绘制来自多个
我正在使用 Zedgraph 的 RollingPointPairList 绘制实时图表。我每秒接收 100 点并尝试每秒绘制 100 点。但是 zedgraph 显示滞后并且每秒最多只能绘制 20
如何减小图表标签和轴标签之间的距离? 最佳答案 您可以使用 GraphPane 的 TitleGap 属性和感兴趣轴的 Scale.LabelGap 属性。 例如: zedGraphControl1.
如果点 > 100,我想永久更改线条颜色;我的意思是我想看到图表上的红线表示数据大于 100,绿线表示数据小于 100。我该怎么做? 如果可能的话,我想要矩形内数据范围的红线。 最佳答案 查看 Gra
我是一名优秀的程序员,十分优秀!