c# - MS Chart axes are drawn trough data points -
i'm working ms charts, , somehow can't figure out way draw points on top of y-axis. can see in image below, points @ x = 0 (label 1998) below y-axis. recognize problem? has order of prepaint , postpaint events?
in chart
datapoints
go over gridlines
under axes
, tickmarks
.
to paint them over axes
need owner draw them in 1 of paint
events.
this simple if charttype
of type points
, spline
or line
, markertype
of circle
or rectangle
.
for other types column
or bar
etc lot harder.
here simple example points
; pick size better..!
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); } }
i have suppressed custom drawing some points.
Comments
Post a Comment