Beispiel #1
0
        public void InsertBarChartIntoWord(MainDocumentPart mainPart, string title)
        {
            // open Word documant and remove existing content from control
            Paragraph para = findAndRemoveContent(mainPart, "Chart1");

            // generate new ChartPart and ChartSpace
            ChartPart chartPart = mainPart.AddNewPart<ChartPart>();
            string relId = mainPart.GetIdOfPart(chartPart);

            AllocationComparisonBarChart bc = new AllocationComparisonBarChart();
            C.Chart chart = bc.GenerateChart(title, null);
            C.ChartSpace chartSpace = GraphSpace.GenerateChartSpace(chart);

            // set ChartPart ChartSpace
            chartPart.ChartSpace = chartSpace;

            // generate Pie Chart and add to ChartSpace
            //StressBarChart bc = new StressBarChart();
            chartSpace.Append(chart);

            // set ChartPart ChartSpace
            chartPart.ChartSpace = chartSpace;

            // generate a new Wordprocessing Drawing, add to a new Run,
            // and relate to new ChartPart
            Run run = new Run();
            Drawing drawing = GraphDrawing.GenerateDrawing(relId, "Chart 1", 2U, Graph.Cx, Graph.Cy);
            para.Append(run);
            run.Append(drawing);

            // save and close document
            mainPart.Document.Save();
        }
Beispiel #2
0
        public ChartItem AllocationComparison()
        {
            // get chart specs
            XElement rpt = chartSpec("allocation-comparison");
            decimal x = (decimal?)rpt.Attribute("size-x") ?? DefaultSizeX;
            decimal y = (decimal?)rpt.Attribute("size-y") ?? DefaultSizeY;

            // set title
            string title = String.Format(rpt.Element("title").Value, StrategyName);

            var comp = DataContext.ClientWeightingComparison(Client.GUID, Client.StrategyID);
            var diff = from c in comp
                       let weight = Client.HighNetWorth ? c.WeightingDifferenceHNW : c.WeightingDifferenceAffluent
                       select new AssetWeighting { AssetClass = c.AssetClassName, Weighting = weight };
            var data = diff.ToList();

            AllocationComparisonBarChart bc = new AllocationComparisonBarChart();
            C.Chart chart = bc.GenerateChart(title, data);

            string ccn = rpt.Element("control-name").Value;
            ChartItem chartItem = new ChartItem
            {
                Chart = chart,
                Title = title,
                CustomControlName = ccn,
                SizeX = x,
                SizeY = y,
                GraphData = bc.GraphData
            };

            return chartItem;
        }