51 lines
		
	
	
		
			1.7 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
			
		
		
	
	
			51 lines
		
	
	
		
			1.7 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
| using System.Collections;
 | |
| using System.Web.Mvc;
 | |
| using Kendo.Mvc.UI;
 | |
| using Kendo.Mvc.UI.Fluent;
 | |
| using Kreta.BusinessLogic.Utils;
 | |
| 
 | |
| namespace Kreta.Web.Helpers
 | |
| {
 | |
|     public static class ChartExtensions
 | |
|     {
 | |
|         public static ChartBuilder<object> KretaChart<T>(
 | |
|             this HtmlHelper<T> helper,
 | |
|             string name,
 | |
|             int title,
 | |
|             ChartLegendPosition legendPos,
 | |
|             IEnumerable seriesCol,
 | |
|             IEnumerable categoryAxisCol,
 | |
|             int labelRotation = -90,
 | |
|             bool majorGridLinesVisible = false,
 | |
|             int valueAxisMax = 5,
 | |
|             bool valueAxisVisible = false,
 | |
|             bool tooltipVisible = false,
 | |
|             string tooltipFormat = "{ 0:0.00}")
 | |
|         {
 | |
|             var chart = helper.Kendo().Chart()
 | |
|                 .Name(name)
 | |
|                 .Title(StringResourcesUtils.GetString(title))
 | |
|                 .Legend(legend => legend.Position(legendPos))
 | |
|                 .ChartArea(chartArea => chartArea.Background("transparent"))
 | |
|                 .Series(series => series
 | |
|                     .Column(seriesCol)
 | |
|                     .Color("#406a7c")
 | |
|                 )
 | |
|                 .CategoryAxis(axis => axis
 | |
|                     .Categories(categoryAxisCol)
 | |
|                     .Labels(labels => labels.Rotation(labelRotation))
 | |
|                     .MajorGridLines(lines => lines.Visible(majorGridLinesVisible))
 | |
|                 )
 | |
|                 .ValueAxis(axis => axis
 | |
|                     .Numeric()
 | |
|                     .Line(line => line.Visible(valueAxisVisible))
 | |
|                 )
 | |
|                 .Tooltip(tooltip => tooltip
 | |
|                     .Visible(tooltipVisible)
 | |
|                     .Format(tooltipFormat)
 | |
|                 );
 | |
|             return chart;
 | |
|         }
 | |
|     }
 | |
| }
 |