c# - Data Points Not Visible When Using CustomLabel -


i'm trying produce chart shows data points each hour of last 24 hours using .net chart control (system.windows.forms.datavisualization.charting). want x-axis have 2 rows, top row showing hour in format "8pm" ("htt") , bottom row showing date in form of "07/16" ("mm\\/dd"). problem code below custom label not show unless uncomment 2 lines have been commented out. but, when do, data points disappear. what's going on? how can show data points , custom label?

as side question, don't understand why have add 2 dayofyear on axisx.maximum. seems should have add 1.

chart1.series.clear(); var series = chart1.series.add("trend"); series.xvaluemember = "date"; series.xvaluetype = chartvaluetype.datetime; series.yvaluemembers = "count"; series.yvaluetype = chartvaluetype.int32; series.charttype = seriescharttype.line; series.markerstyle = markerstyle.circle; series.markersize = 16; series.borderwidth = 10; chart1.chartareas[0].axisx.intervaloffsettype = datetimeintervaltype.days; chart1.chartareas[0].axisx.interval = 1; chart1.chartareas[0].axisx.intervaloffset = 0; //chart1.chartareas[0].axisx.minimum = datetime.now.dayofyear; //chart1.chartareas[0].axisx.maximum = datetime.now.dayofyear + 2; chart1.chartareas[0].axisx.majorgrid.enabled = false; chart1.chartareas[0].axisx.intervaltype = datetimeintervaltype.hours; chart1.chartareas[0].axisx.labelstyle.format = "htt"; chart1.chartareas[0].axisx.labelstyle.angle = -60; chart1.chartareas[0].axisx.customlabels.add(1, datetimeintervaltype.days, "mm\\/dd", 1, labelmarkstyle.linesidemark); 

here's chart looks when 2 lines commented out. notice custom label not show up.

when lines commented out

and here's chart looks when 2 lines uncommented. notice data points missing, custom label day shows up.

when lines uncommented

i got chart below similar description:

enter image description here

in order minimum , maximum set follows:

chart1.chartareas[0].axisx.minimum = datetime.now.tooadate(); chart1.chartareas[0].axisx.maximum = datetime.now.addhours(24).tooadate(); 

so, if change way minimum , maximum set, should display custom labels along data points together.

edit 1: ok, managed custom label yours, setting minimum , maximum described before:

enter image description here:

for practical purposes of "x-axis arithmetic", setting minimum , maximum, need use tooadate() returns floating-point representing number of days before/after december 30 1899 (https://msdn.microsoft.com/en-us/library/system.datetime.tooadate%28v=vs.110%29.aspx); dayofyear retuns integer , inappropriate in such situation.


Comments

Popular posts from this blog

c# - Better 64-bit byte array hash -

webrtc - Which ICE candidate am I using and why? -

php - Zend Framework / Skeleton-Application / Composer install issue -