c# - How Can I get a 0 Neutral in my Y Axis all the time like what ever value it takes? -
getmaximum = gain.max(); <-- list of value numbers random takes out maximum getminumumval = gain.min(); <-- takes out minimum xaxisscale = gaincounter; if (xaxisscale % 10 != 0) { xaxisscale = (xaxisscale - xaxisscale % 10) + 10; <-- round off nearest highest 10th } intervalxaxis = xaxisscale / 5; <-- divide interval 5 //------------- y axis ---- needs 0 neutral ----- // if(getminumumval > -40) { getminumumval = -40; converttopos = -40; <-- default lowest -40 } else { if (getminumumval % 10 != 0) { getminumumval = (getminumumval - getminumumval % 10) - 10; } converttopos = convert.toint32(getminumumval) * -1; } //-------------// if(getmaximum > 60) { getmaximum = gain.max(); if (getmaximum % 10 != 0) { getmaximum = (getmaximum - getmaximum % 10) + 10; } } else { getmaximum = 60; <-- default highest 60 } getinterval = (convert.toint32(getmaximum) + converttopos) / 10; <-- divide 10 need have 0 neutral on it?? problem trade_analyzer_panel.chart1a.chartareas.add("area1a"); trade_analyzer_panel.chart1a.titles.add("gain / loss product xyz");// trade_analyzer_panel.chart1a.series.add("gain/loss"); trade_analyzer_panel.chart1a.legends.add("gain/loss"); trade_analyzer_panel.chart1a.series["gain/loss"].charttype = system.windows.forms.datavisualization.charting.seriescharttype.column; count = 0; (int = 0; < trade_analyzer_panel.datagridview1.rows.count - 1; i++) { trade_analyzer_panel.chart1a.series["gain/loss"].color = color.blue; //trade_analyzer_panel.chart1a.series["gain/loss"].points[count].axislabel = convert.toint32(gain[count]).tostring(); trade_analyzer_panel.chart1a.series["gain/loss"].points.addxy(count, convert.toint32(gain[count])); count++; } // -------- horizontal ---------- // trade_analyzer_panel.chart1a.chartareas["area1a"].axisx.minimum = 1; trade_analyzer_panel.chart1a.chartareas["area1a"].axisx.maximum = xaxisscale; trade_analyzer_panel.chart1a.chartareas["area1a"].axisx.interval = 5; //intervalxaxis; // -------- vertical ---------- // trade_analyzer_panel.chart1a.chartareas["area1a"].axisy.minimum = convert.toint32(getminumumval); trade_analyzer_panel.chart1a.chartareas["area1a"].axisy.maximum = convert.toint32(getmaximum); trade_analyzer_panel.chart1a.chartareas["area1a"].axisy.interval = 20; trade_analyzer_panel.chart1a.chartareas["area1a"].axisx.scrollbar.buttonstyle = system.windows.forms.datavisualization.charting.scrollbarbuttonstyles.smallscroll; trade_analyzer_panel.chart1a.chartareas["area1a"].axisx.majorgrid.enabled = false; // set view range [0,max] trade_analyzer_panel.chart1a.chartareas["area1a"].axisx.minimum = 0; trade_analyzer_panel.chart1a.chartareas["area1a"].axisx.maximum = xaxisscale; // enable autoscroll trade_analyzer_panel.chart1a.chartareas["area1a"].cursorx.autoscroll = true; // let's zoom [0,blocksize] (e.g. [0,5]) trade_analyzer_panel.chart1a.chartareas["area1a"].axisx.scaleview.zoomable = true; trade_analyzer_panel.chart1a.chartareas["area1a"].axisx.scaleview.sizetype = system.windows.forms.datavisualization.charting.datetimeintervaltype.number; trade_analyzer_panel.chart1a.chartareas["area1a"].axisx.scaleview.zoom(0, 5); // disable zoom-reset button (only scrollbar's arrows available) trade_analyzer_panel.chart1a.chartareas["area1a"].axisx.scrollbar.buttonstyle = system.windows.forms.datavisualization.charting.scrollbarbuttonstyles.smallscroll; // set scrollbar small change blocksize (e.g. 100) trade_analyzer_panel.chart1a.chartareas["area1a"].axisx.scaleview.smallscrollsize = 100;
should use interval on this? or idea how can 0 neutral highest , lowest value of y axis in chart.. need bad got runned out of ideas sorry
example:
60
40
20
0
-20
-40
but if example lower gets -70 looks this:
50
30
10
-10
-30
-50
-70
how can neutral 0 on no matter how changes are?
note vertical interval 20
trade_analyzer_panel.chart1a.chartareas["area1a"].axisy.interval = 20;
this means steps axis lowest value plus multiples of 20. 0 on 1 of steps if bottom value multiple of 20. may work is
if(getminumumval > -40) { getminumumval = -40; converttopos = -40; <-- default lowest -40 } else { if (getminumumval % 20 != 0) { getminumumval = (getminumumval - getminumumval % 20) - 20; } converttopos = convert.toint32(getminumumval) * -1; }
using 20 rather 10.
note modulus operator % behaves strangely negative numbers see http://en.wikipedia.org/wiki/modulo_operation. if x negative x % 20 negative number. may find things easier use math.floor(getminumumval / 20)*20
smallest multiple of 20 less getminumumval.
Comments
Post a Comment