c# - OxyPlot WPF - Get slected column -
i trying selected (clicked) column in oxyplot wpf. there way that? wpf code far:
<oxy:plot x:name="plotdiagram" title="output" > <oxy:plot.axes> <oxy:categoryaxis itemssource="{binding item.bardisplaydata1}" labelfield="displaytext"/> <oxy:linearaxis minimumpadding="0" absoluteminimum="0"/> </oxy:plot.axes> <oxy:plot.series> <oxy:columnseries title="{binding item.title1}" fillcolor="green" isstacked="true" itemssource="{binding item.bardisplaydata1}" valuefield="value" /> <oxy:columnseries title="{binding item.title2}" fillcolor="red" isstacked="true" itemssource="{binding item.bardisplaydata2}" valuefield="value"/> <oxy:columnseries title="{binding item.title3}" fillcolor="yellow" isstacked="true" itemssource="{binding item.bardisplaydata3}" valuefield="value"/> </oxy:plot.series> </oxy:plot>
there no selected column property. need implement mousedown event on column series , determine column clicked using getnearestpoint() function.
void columns_mousedown(object sender, mousebuttoneventargs e) { var cols = sender columnseries; oxymousedowneventargs args = converterextensions.tomousedowneventargs(e, sender); if (cols != null) { trackerhitresult nearestpoint = cols.getnearestpoint(args.position, false); if(nearestpoint != null) { object selectedcolumn = nearestpoint.item; } } }
Comments
Post a Comment