/ Published in: C#
grafikas atvaizduojamas kreive, pyrago forma, stulpeliais. Pateikiamas kaip sugeneruotas png failas.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
// kodas chtml faile: // <img src="@Url.Action("grafikas")" alt="Drawing chart with HTML Helper" /> // kodas kontroleryje: [ActionName("grafikas")] // ---------------- galima keist path pagal regionus! //[OutputCache(Duration = 3)] // ------------ jei nustatomas keshavimas, kai issaugot bandai gaunasi .bmp failas public ActionResult DrawChart() { /* * reikia pasiimt i������¡ sistemos userio Guid, tai nereik����¯�¿�½s nieko perduot per parametrus!!! */ for (int i = 1; i < 10; i++) { arrXvalues[i] = i.ToString(); arrYvalues[i] = i.ToString() + rn.Next(10).ToString(); } string myTheme = @"<Chart BackColor=""255, 255, 255"" > <ChartAreas> <ChartArea Name=""Default"" BorderColor=""255, 255, 255"" BorderDashStyle=""Solid"" BackColor=""Transparent"" ShadowColor=""Transparent""> <AxisY LineColor=""64, 64, 64, 64""> <MajorGrid Interval=""Auto"" LineColor=""64, 64, 64, 64"" /> <LabelStyle Font=""Trebuchet MS, 8.25pt"" /> </AxisY> <AxisX LineColor=""64, 64, 64, 64""> <MajorGrid Interval=""Auto"" LineColor=""64, 64, 64, 64"" /> <LabelStyle Interval=""Auto"" Font=""Trebuchet MS, 8.25pt"" /> </AxisX> </ChartArea> </ChartAreas> </Chart>"; .AddSeries( chartType: "line", xValue: arrXvalues, yValues: arrYvalues) .GetBytes("png"); return File(chart, "image/bytes"); }