예제 #1
0
 public static void SetLegendOrientation(this PlotModel plot, LegendOrientation orientation)
 {
     foreach (LegendBase legend in plot.Legends)
     {
         legend.LegendOrientation = orientation;
     }
 }
예제 #2
0
        void IChartLegend <SkiaSharpDrawingContext> .Draw(Chart <SkiaSharpDrawingContext> chart)
        {
            var wfChart = (Chart)chart.View;

            var series            = chart.ChartSeries;
            var legendOrientation = chart.LegendOrientation;
            var legendPosition    = chart.LegendPosition;

            switch (legendPosition)
            {
            case LegendPosition.Hidden:
                Visible = false;
                break;

            case LegendPosition.Top:
                Visible = true;
                if (legendOrientation == LegendOrientation.Auto)
                {
                    Orientation = LegendOrientation.Horizontal;
                }
                Dock = DockStyle.Top;
                break;

            case LegendPosition.Left:
                Visible = true;
                if (legendOrientation == LegendOrientation.Auto)
                {
                    Orientation = LegendOrientation.Vertical;
                }
                Dock = DockStyle.Left;
                break;

            case LegendPosition.Right:
                Visible = true;
                if (legendOrientation == LegendOrientation.Auto)
                {
                    Orientation = LegendOrientation.Vertical;
                }
                Dock = DockStyle.Right;
                break;

            case LegendPosition.Bottom:
                Visible = true;
                if (legendOrientation == LegendOrientation.Auto)
                {
                    Orientation = LegendOrientation.Horizontal;
                }
                Dock = DockStyle.Bottom;
                break;

            default:
                break;
            }

            DrawAndMesure(series, wfChart);

            BackColor = wfChart.LegendBackColor;
        }
예제 #3
0
        public void Draw(Chart <SkiaSharpDrawingContext> chart)
        {
            var wfChart = (Chart)chart.View;

            var series            = chart.DrawableSeries;
            var legendOrientation = chart.LegendOrientation;

            Visible = true;
            if (legendOrientation == LegendOrientation.Auto)
            {
                Orientation = LegendOrientation.Vertical;
            }
            Dock = DockStyle.Right;

            DrawAndMesure(series, wfChart);

            BackColor = wfChart.LegendBackColor;
        }
예제 #4
0
 public static PlotModel getPlotModel(
     String title,
     TitleHorizontalAlignment titleHorizontalAlignment,
     String legendTitle,
     LegendOrientation legendOrientation,
     LegendPlacement legendPlacement,
     LegendPosition legendPosition)
 {
     return(new PlotModel
     {
         Title = title,
         TitleHorizontalAlignment = titleHorizontalAlignment,
         LegendTitle = legendTitle,
         LegendOrientation = legendOrientation,
         LegendPlacement = legendPlacement,
         LegendPosition = legendPosition
     });
 }
예제 #5
0
        private void UpdateThrottlerUnlocked()
        {
            // before measure every element in the chart
            // we copy the properties that might change while we are updating the chart
            // this call should be thread safe
            // ToDo: ensure it is thread safe...

            viewDrawMargin = chartView.DrawMargin;
            controlSize    = chartView.ControlSize;
            yAxes          = chartView.YAxes.Select(x => x.Copy()).ToArray();
            xAxes          = chartView.XAxes.Select(x => x.Copy()).ToArray();

            measureWorker = new object();
            series        = chartView.Series.Select(series =>
            {
                // a good implementation of ISeries<T>
                // must use the measureWorker to identify
                // if the points are already fetched.

                // this way no matter if the Series.Values collection changes
                // the fetch method will always return the same collection for the
                // current measureWorker instance

                series.Fetch(this);
                return(series);
            }).ToArray();

            legendPosition    = chartView.LegendPosition;
            legendOrientation = chartView.LegendOrientation;
            legend            = chartView.Legend; // ... this is a reference type.. this has no sense

            tooltipPosition        = chartView.TooltipPosition;
            tooltipFindingStrategy = chartView.TooltipFindingStrategy;
            tooltip = chartView.Tooltip; //... no sense again...

            animationsSpeed = chartView.AnimationsSpeed;
            easingFunction  = chartView.EasingFunction;

            Measure();
        }
예제 #6
0
        private static string[] GetLegendString(LegendOrientation orientation, string[] arguments, string[] labels)
        {
            var chars = orientation == LegendOrientation.Above ? "┌┬┐" : "└┴┘";

            var result = new string[arguments.Length];

            for (int i = 0; i < arguments.Length; i++)
            {
                var length = arguments[i].Length;

                if (length == 0)
                {
                    result[i] = "";
                }
                else
                {
                    result[i] = "".PadRight(length, '─');

                    if (length == 1)
                    {
                        result[i] = chars[1].ToString();
                    }
                    else
                    {
                        result[i] = chars[0].ToString() + result[i].Substring(1, length - 2) + chars[2].ToString();
                    }

                    if (length > 3)
                    {
                        var label          = labels[i];
                        int charsLeftRight = (result[i].Length - label.Length) / 2;
                        int charsLeft      = (charsLeftRight * 2 + label.Length == result[i].Length) ? charsLeftRight : charsLeftRight + 1;
                        result[i] = result[i].Substring(0, charsLeft) + label + result[i].Substring(result[i].Length - charsLeftRight, charsLeftRight);
                    }
                }
            }

            return(result);
        }
예제 #7
0
 /// <summary>
 /// Create a Legend instance.
 /// </summary>
 /// <param name="orientation">Legend orientation.</param>
 /// <param name="position">Legend position.</param>
 /// <param name="insideGraph">Should the legend be displayed inside the graph area?</param>
 public LegendConfiguration(LegendOrientation orientation, LegendPosition position, bool insideGraph)
 {
     Orientation     = orientation;
     Position        = position;
     InsideGraphArea = insideGraph;
 }