Ejemplo n.º 1
0
    private void PrepareChartData()
    {
        if (Session["points"] == null)
        {
            Session["points"] = new List <MySeriesPoint>();
        }

        ((List <MySeriesPoint>)Session["points"]).Clear();

        if (hfDataSourceType.Value == "column")
        {
            for (int i = 0; i < ASPxPivotGrid1.RowCount; i++)
            {
                string argument = Convert.ToString(ASPxPivotGrid1.GetFieldValue(ASPxPivotGrid1.Fields["MyRow"], i));

                if (string.IsNullOrEmpty(argument))
                {
                    argument = "Grand Total";
                }

                decimal value = Convert.ToDecimal(ASPxPivotGrid1.GetCellValue(this.SelectedColumnIndex, i));

                ((List <MySeriesPoint>)Session["points"]).Add(new MySeriesPoint(argument, Convert.ToDouble(value)));
            }
        }
        else
        {
            for (int i = 0; i < ASPxPivotGrid1.ColumnCount; i++)
            {
                string argument = Convert.ToString(ASPxPivotGrid1.GetFieldValue(ASPxPivotGrid1.Fields["MyDateTime"], i));

                if (string.IsNullOrEmpty(argument))
                {
                    argument = "Grand Total";
                }

                decimal value = Convert.ToDecimal(ASPxPivotGrid1.GetCellValue(i, this.SelectedRowIndex));

                ((List <MySeriesPoint>)Session["points"]).Add(new MySeriesPoint(argument, Convert.ToDouble(value)));
            }
        }
    }
Ejemplo n.º 2
0
    Dictionary <string, decimal> GetCountrySales()
    {
        Dictionary <string, decimal> res = new Dictionary <string, decimal>();
        bool isColumn = fieldCountry.IsColumn;
        int  count    = isColumn ? ASPxPivotGrid1.ColumnCount : ASPxPivotGrid1.RowCount;

        for (int i = 0; i < count; i++)
        {
            string country = (string)ASPxPivotGrid1.GetFieldValue(fieldCountry, i);
            if (string.IsNullOrEmpty(country))
            {
                continue;
            }
            decimal value = Convert.ToDecimal(
                ASPxPivotGrid1.GetCellValue(isColumn ? i : ASPxPivotGrid1.ColumnCount - 1,
                                            isColumn ? ASPxPivotGrid1.RowCount - 1 : i));
            res.Add(country, value);
        }
        return(res);
    }