In the N long ago, I sent a drawing curve of the article first sent a plot of the graph: the use of ASP.net with C # drawing graphs (curve diagram) inside the simple method of drawing graphs. I have been leafing through this article recently. In a great mood, I have revised the drawing method again, Increase the processing of automatic adaptive data and can draw multiple curves based on incoming data
As usual, picture above:
More cool than before, huh? Oh, in fact, according to the data automatically calculate margins and fonts.
<summary>///automatically adjusts image size based on parameters///</summary> public void Fit () {
Calculate font Distance intfontspace = fontsize + 5;
Calculate image margin Float fltspace = math.min (WIDTH/6, HEIGHT/6);
Xspace = Fltspace;
Yspace = Fltspace;
Calculates the x-axis scale width Xslice = (Width-2 * xspace)/(KEYS.LENGTH-1);
Calculates the y-axis tick width and the y-axis tick start value float fltminvalue = 0;
float Fltmaxvalue = 0;
for (int i = 0; i < values.length i++) {if (Values[i] < Fltminvalue) {
Fltminvalue = Values[i];
else if (Values[i] > Fltmaxvalue) {fltmaxvalue = values[i]; } if (Yslicebegin > Fltminvalue) {yslicebegin = Flt
MinValue; int intyslicecount = (int)
(Fltmaxvalue/yslicevalue);
if (fltmaxvalue% yslicevalue!= 0) {intyslicecount++;
} Yslice = (Height-2 * yspace)/intyslicecount; }