2016-05-09 24 views
1

我正在使用MS图表,并且不知何故我找不出一种方法在y轴顶部绘制点。 正如您在下图中看到的那样,x = 0处的点(标签1998)低于Y轴。 有没有人认识到这个问题?它与预涂和后色调事件的顺序有关吗?质谱图坐标轴绘制低谷数据点

axis trough points

编辑:测试自定义绘制点,只有等到y轴.. enter image description here

+0

这是正常的行为。你真的有任何油漆事件吗? – TaW

+0

是的,在OnPostPaint中,我们绘制了自己的Beziercurves –

+0

那么,绘制点并不那么难;你可以使用相同的AxisX.ValueToPixelPosition(dp.XValue); etc功能.. – TaW

回答

1

Chart所有DataPointsGridLinesAxesTickMarks

画他们Axes,以及你需要主人在Paint事件之一绘制他们。

这很简单,如果你的ChartTypePoints类型,SplineLine和您的CircleRectangleMarkerType

对于大多数其他类型,如ColumnBar等,这是一个困难得多。

这里是Points一个简单的例子;选择一个你喜欢的尺寸更好..!

private void chart1_PostPaint(object sender, ChartPaintEventArgs e) 
{ 
    if (chart1.Series.Count == 0) return; 

    Axis AX = chart1.ChartAreas[0].AxisX; 
    Axis AY = chart1.ChartAreas[0].AxisY; 
    chart1.ApplyPaletteColors(); 
    foreach (Series s in chart1.Series) 
     foreach (DataPoint dp in s.Points) 
     { 
      float x = (float)AX.ValueToPixelPosition(dp.XValue); 
      float y = (float)AY.ValueToPixelPosition(dp.YValues[0]); 
      float w2 = 3.6f; 
      using (SolidBrush brush = new SolidBrush(Color.YellowGreen)) 
        e.ChartGraphics.Graphics.FillEllipse(brush, 
                 x - w2, y - w2, w2 * 2f, w2 * 2f); 
     } 
} 

enter image description hereenter image description here

我已经压抑了一些点的自定义绘制。

+0

我已经这样做了,但是现在我遇到了问题,直到在y轴的左侧,您看到自动绘制的点,在y轴的右侧我自己定制的绘制圆.. –

+0

This sohuldn​​'t be。请将您的代码与上面添加的示例进行比较! – TaW

+0

chartAreaRect已经过计算,所以graphics.Clip被设置为这些边界。但是在你的图像中,坐标轴上的点也被画下了? –