draw a graph dynamically in c# condition is that StringBuilder

407 views Asked by At
    StringBuilder mStr = new StringBuilder();

    dtReports = GameLib.Reports.GetReportList();

    mStr.Append("<asp:Chart ID='Graph' >");
    mStr.Append("<Series>");

    mStr.Append(" </asp:Series>");
    mStr.Append("</Series>");
    mStr.Append("<ChartAreas>");
    mStr.Append("<asp:ChartArea Name='ChartArea1' BorderColor='64, 64, 64, 64' BackSecondaryColor='White'>");

    mStr.Append("<Area3DStyle Rotation='1' Perspective='10' Inclination='15' IsRightAngleAxes='False' WallWidth='0' Enable3D='false' IsClustered='False'>");
    mStr.Append("</Area3DStyle>");
    mStr.Append("<AxisY LineColor='64, 64, 64, 64' LabelAutoFitMinFontSize='5' TitleFont='Arial', 14pt, style='Bold'TitleForeColor='Black'>");
   mStr.Append("<LabelStyle Font='Arial', style='Bold' ForeColor='Black' />");
   mStr.Append("<MajorGrid LineColor='64, 64, 64, 64' />");
   mStr.Append("</AxisY>");
   mStr.Append("<AxisX LineColor='64, 64, 64, 64' LabelAutoFitMinFontSize='5'     Interval='Auto' TitleFont='Arial, 14pt, style=Bold' ,TitleForeColor='Black'>");

   mStr.Append(" <LabelStyle Font='Arial, 12pt, style=Bold', ForeColor='Black' >");
   mStr.Append("<MajorGrid LineColor='64, 64, 64, 64' />");
   mStr.Append("</AxisX>");
   mStr.Append("<%--<Position Height='75.02613' Width='90.26034' X='5.55474472' Y='14.414547' />--%>")
   mStr.Append(" </asp:ChartArea>");
   mStr.Append(" </ChartAreas>");
   mStr.Append("</asp:Chart>");
   mStr.Append("</div>");

This is code for graph to create dynamically,please help solve this error,some height and width detail deleted.please explain me how solve issue

1

There are 1 answers

0
Simon On

OMG Use control mate

var chart = new Chart();
var series = new Series();
series.XValueMember = "Age";
//and so on

//on the page
this.Controls.Add(chart);

//or if you want add it to panel
panel.Controls.Add(chart);`

or you can use your code but you need to build it dynamicly using CompilerService after that you should render it and after you have to set it in to some elements innerHtml and so on...