Ejemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="error"></param>
        /// <param name="context"></param>
        public override void RenderError(Exception error, IMvcContext context)
        {
            var config = ChartConfig.Create(error);
            var script = GetErrorChartContent(context, config);

            context.StatusCode = 500;
            context.Output.Write(script);
        }
Ejemplo n.º 2
0
        private IChartConfig PrepareChartConfig(IMvcContext context)
        {
            if (context.ActionResult is IChartConfig)
            {
                return(context.ActionResult as IChartConfig);
            }
            if (context.ActionResult is Exception)
            {
                return(ChartConfig.Create(context.ActionResult as Exception));
            }


            var result = new ChartConfig {
                Id        = context.Get("id", DateTime.Now.Ticks).ToString(CultureInfo.InvariantCulture),
                Container = context.Get("container", string.Empty),
                Width     = context.Get("width", "400"),
                Height    = context.Get("height", "300"),
                Debug     = context.Get("debug", "0"),
                Type      = context.Get("type", "Column2D"),
                Divlines  = context.Get("divlines", -1)
            };
            var specAttrs = context.GetAll("fc");

            foreach (var attr in specAttrs)
            {
                result.Set(attr.Key, attr.Value);
            }



            if (context.ActionResult is ChartState)
            {
                result.State = context.ActionResult as ChartState;
            }
            else
            {
                result.NativeResult = context.ActionResult;
            }



            return(result);
        }