Ejemplo n.º 1
0
        public static MvcHtmlString DrawChart(ChartModel chartmodel, string charttype, string element)
        {
            string result = "";

            string columns = GetChartColumns(chartmodel.columns);
            string rows = GetChartRows(chartmodel.rows);
            string options = GetChartOptions(chartmodel.Options);

            result = string.Format(scriptstring, columns, rows, options, charttype, element);
            return new MvcHtmlString(result);
        }
Ejemplo n.º 2
0
        // GET: Chart
        public ActionResult Index()
        {
            ChartModel model = new ChartModel();

            model.columns.Add("string", "Topping");
            model.columns.Add("number", "Slices");

            DataTable dt = new DataTable();
            dt.Clear();
            dt.Columns.Add("Topping");
            dt.Columns.Add("Slices");
            dt.Columns["Slices"].DataType = System.Type.GetType("System.Int32");

            DataRow dr = dt.NewRow();
            dr["Topping"] = "Mushrooms";
            dr["Slices"] = 3;
            dt.Rows.Add(dr);

            dr = dt.NewRow();
            dr["Topping"] = "Onions";
            dr["Slices"] = 3;
            dt.Rows.Add(dr);

            dr = dt.NewRow();
            dr["Topping"] = "Olives";
            dr["Slices"] = 1;
            dt.Rows.Add(dr);

            dr = dt.NewRow();
            dr["Topping"] = "Zucchini";
            dr["Slices"] = 1;
            dt.Rows.Add(dr);

            dr = dt.NewRow();
            dr["Topping"] = "Pepperoni";
            dr["Slices"] = 2;
            dt.Rows.Add(dr);

            model.rows = dt;

            model.Options.Add("Width", "100%");
            model.Options.Add("Height", "65%");
            model.Options.Add("Title", "My pie chart");

            return View(model);
        }