Example #1
0
        public void AddLegend(Canvas canvas, DataCollection<DataSeries> dc)
        {
            if (dc.DataList.Count == 0 || !IsLegend)
            {
                return;
            }

            const double textHeight = 17;
            const double lineLength = 34;
            double legendWidth = dc.CalculateLegendWidth();
            double legendHeight = dc.CalculateLegendHeight(textHeight);
            Rectangle legendRect = Canvas.GenerateLegendRect(legendWidth+lineLength+20, legendHeight+5);
            if (IsLegend && IsBorder)
            {
                Canvas.Children.Add(legendRect);
            }
            Canvas.GenerateLegendLines(dc.DataList, textHeight, lineLength);
            SetCanvasPosition(canvas, legendRect);
        }
 public LineChartControlLib()
 {
     InitializeComponent();
     ChartStyle = new ChartStyleGridLines();
     DataCollection = new DataCollection<DataSeries>();
     DataSeries = new DataSeries();
     ChartStyle.TextCanvas = TextCanvas;
     ChartStyle.ChartCanvas = ChartCanvas;
     Legend = new NorthEastLegend {Canvas = LegendCanvas};
 }