Bunun için custom theme kullanılması gerekmektedir. Option olarak dışarıdan set edilememektedir.
Örnek olarak grafikde Y value bilgisini gösteren theme bilgisi şu şekildedir:
Controller içideki kod:
public ActionResult GetChartImage()
{
string tVanilla =
@"<Chart Palette=""SemiTransparent"" BorderColor=""#000"" BorderWidth=""2"" BorderlineDashStyle=""Solid"">
<ChartAreas>
<ChartArea _Template_=""All"" Name=""Default"">
<AxisX>
<MinorGrid Enabled=""False"" />
<MajorGrid Enabled=""False"" />
</AxisX>
<AxisY>
<MajorGrid Enabled=""False"" />
<MinorGrid Enabled=""False"" />
</AxisY>
</ChartArea>
</ChartAreas>
<Series>
<Series
_Template_=""All""
BorderWidth=""0""
LabelForeColor=""#000000""
LabelBackColor=""#FFFFFF""
IsValueShownAsLabel=""true"" >
</Series>
</Series>
</Chart>";
new System.Web.Helpers.Chart(
width: 400
, height: 200
//, theme: ChartTheme.Blue
//, theme:ChartTheme.Vanilla
, theme:tVanilla
)
.AddTitle("Ders Notları")
.AddSeries(
chartType: "column"
//chartType: "bar"
, name:"Dersler"
, axisLabel:"Ders Adı"
, xValue: new[] {"Math", "English", "Computer", "Science1"}
, yValues: new[] {"80", "90", "78", "68"}
)
.Write("png");
return null;
}
View Razor kısmındaki kod:
<img src="@Url.Action("GetChartImage", new { dateTime=DateTime.Now.ToString("yyyyMMyyHHmmss") })" alt="" />
şeklinde kullanılabilir:
Kaynaklar:
http://stackoverflow.com/questions/10657538/applying-a-default-theme-to-a-chart-series
http://aspnetwebstack.codeplex.com/SourceControl/changeset/view/7e0749a2db9c#src/System.Web.Helpers/Chart/ChartTheme.cs
C#, .NET, .Net Core
ASP.NET MVC, ASP.NET Web Forms, ASP.NET Core
HTML 5, CSS 3, Javascript, jQuery, Bootstrap
Entity Framework, NHibernate, Dapper
Sql Server, MySql, Oracle
Windows Server, Ubuntu, Debian, Pardus
Xamarin Forms, Android Studio
--- The future of the open web platform is looking very bright!
--- .NET is a free, cross-platform, open source developer platform for building any app.
Google Analytics İzleme
Kaydol:
Kayıt Yorumları (Atom)
Hiç yorum yok:
Yorum Gönder