Beispiel #1
0
        /// <summary>
        ///  Centers the viewport around the specified position(x-index and y-value)
        /// in the chart.Centering the viewport outside the bounds of the chart is
        /// not possible. Makes most sense in combination with the
        /// setScaleMinima(...) method.
        /// </summary>
        /// <param name="transformedPts">the position to center view viewport to</param>
        /// <param name="view"></param>
        public void CenterViewPort(SKPoint transformedPts, IChartBase view)
        {
            float x = transformedPts.X - OffsetLeft;
            float y = transformedPts.Y - OffsetTop;

            Refresh(touchMatrix.PostConcat(SKMatrix.CreateTranslation(-x, -y)), view, true);
        }
Beispiel #2
0
        /// <summary>
        /// Centers the viewport around the specified position (x-index and y-value) in the chart.
        /// Centering the viewport outside the bounds of the chart is not possible.
        /// Makes most sense in combination with the setScaleMinima(...) method.
        /// </summary>
        public void CenterViewPort(CGPoint pt, IChartBase chart)
        {
            var translateX = pt.X - OffsetLeft;
            var translateY = pt.Y - OffsetTop;
            var matrix     = touchMatrix * CGAffineTransform.MakeTranslation(-translateX, -translateY);

            Refresh(matrix, chart: chart, invalidate: true);
        }
        public object ValueDefinitionObj => ValueDefinition; //object required for polymorphisim

        public QueryToken?GetToken(IChartBase chartBase)
        {
            if (this.ColumnIndex == null)
            {
                return(null);
            }

            return(chartBase.Columns[this.ColumnIndex.Value].Token?.Token);
        }
Beispiel #4
0
        public CGAffineTransform Refresh(CGAffineTransform newMtrix, IChartBase chart, bool invalidate)
        {
            touchMatrix = LimitTransAndScale(newMtrix, contentRect);

            if (invalidate)
            {
                chart.SetNeedsDisplay();
            }

            return(touchMatrix);
        }
Beispiel #5
0
        internal static void FixParameters(IChartBase chart, ChartColumnEmbedded chartColumn)
        {
            int index = chart.Columns.IndexOf(chartColumn);

            foreach (var p in chart.Parameters.Where(p => p.ScriptParameter.ColumnIndex == index))
            {
                if (p.PropertyCheck(() => p.Value).HasText())
                {
                    p.Value = p.ScriptParameter.DefaultValue(chartColumn.Token?.Token);
                }
            }
        }
Beispiel #6
0
        public Matrix Refresh(Matrix newMtrix, IChartBase chart, bool invalidate)
        {
            touchMatrix.Set(newMtrix);

            LimitTransAndScale(touchMatrix, contentRect);

            if (invalidate)
            {
                chart.Invalidate();
            }
            newMtrix.Set(touchMatrix);
            return(newMtrix);
        }
Beispiel #7
0
        /// <summary>
        ///  Centers the viewport around the specified position(x-index and y-value)
        /// in the chart.Centering the viewport outside the bounds of the chart is
        /// not possible. Makes most sense in combination with the
        /// setScaleMinima(...) method.
        /// </summary>
        /// <param name="transformedPts">the position to center view viewport to</param>
        /// <param name="view"></param>
        public void CenterViewPort(float[] transformedPts, IChartBase view)
        {
            Matrix save = CenterViewPortMatrixBuffer;

            save.Reset();
            save.Set(touchMatrix);

            float x = transformedPts[0] - OffsetLeft;
            float y = transformedPts[1] - OffsetTop;

            save.PostTranslate(-x, -y);

            Refresh(save, view, true);
        }
Beispiel #8
0
        public SKMatrix Refresh(SKMatrix newMtrix, IChartBase chart, bool invalidate)
        {
            touchMatrix = LimitTransAndScale(newMtrix, contentRect);

            if (invalidate)
            {
#if WPF
                chart.InvalidateVisual();
#else
                chart.InvalidateSurface();
#endif
            }

            return(touchMatrix);
        }
Beispiel #9
0
        public static string ChartTypeImgClass(IChartBase chartBase, ChartScriptEntity current, ChartScriptEntity script)
        {
            string css = "sf-chart-img";

            if (!chartBase.Columns.Any(a => a.Token != null && a.Token.ParseException != null) && script.IsCompatibleWith(chartBase))
            {
                css += " sf-chart-img-equiv";
            }

            if (script.Is(current))
            {
                css += " sf-chart-img-curr";
            }

            return(css);
        }
Beispiel #10
0
        /// <summary>
        /// Overloaded constructor used create an instance of the LegendModel class during serialization.
        /// The public properties of this class are set by this contructor as they are obtained from the
        /// ILegend interface object passed as the parameter.
        /// </summary>
        /// <param name="legend">Specifies the ILegend interface object to be serialized.</param>
        /// <param name="chart">Specifies the IChart interface object of the parent IChart object being serialized.</param>
        public LegendModel(ILegend legend, IChartBase chart)
        {
            Position    = legend.Position;
            Orientation = legend.Orientation;
            Title       = legend.Title;
            Reversed    = legend.Reversed;

#if WINFORMS
            Style      = StyleSerializer.StyleToString(legend.GetStyle("_"), chart as IBrushConverter);
            TitleStyle = StyleSerializer.StyleToString(legend.GetStyle("_Title"), chart as IBrushConverter);
#endif
#if WPF
            Style      = StyleSerializer.StyleToString(legend.GetStyle(), chart as IBrushConverter);
            TitleStyle = StyleSerializer.StyleToString(legend.GetStyle("Title"), chart as IBrushConverter);
#endif
        }
Beispiel #11
0
        public void Draw(SKCanvas canvas, SKPoint pos, IChartBase chart)
        {
            var renderer = GetRenderer();

            if (renderer != null)
            {
                var offset = GetOffsetForDrawingAtPoint(pos, renderer.CanvasInfo, chart);
                int saveId = canvas.Save();
                OnDraw(canvas, pos, chart);
                // translate to the correct position and draw
                canvas.Translate(pos.X + offset.X, pos.Y + offset.Y);

                renderer.Draw(canvas);
                canvas.RestoreToCount(saveId);
            }
        }
Beispiel #12
0
        public bool IsCompatibleWith(IChartBase chartBase)
        {
            if (GroupBy == GroupByChart.Always && !chartBase.GroupResults)
            {
                return(false);
            }

            if (GroupBy == GroupByChart.Never && chartBase.GroupResults)
            {
                return(false);
            }

            return(Columns.ZipOrDefault(chartBase.Columns, (s, c) =>
            {
                if (s == null)
                {
                    return c.Token == null;
                }

                if (c == null || c.Token == null)
                {
                    return s.IsOptional;
                }

                if (!ChartUtils.IsChartColumnType(c.Token.Token, s.ColumnType))
                {
                    return false;
                }

                if (c.Token.Token is AggregateToken)
                {
                    return !s.IsGroupKey;
                }
                else
                {
                    return s.IsGroupKey || !chartBase.GroupResults;
                }
            }).All(a => a));
        }
Beispiel #13
0
        public static bool SynchronizeColumns(this ChartScriptEntity chartScript, IChartBase chart)
        {
            bool result = false;

            if (chartScript == null)
            {
                result = true;
                chart.Columns.Clear();
            }

            for (int i = 0; i < chartScript.Columns.Count; i++)
            {
                if (chart.Columns.Count <= i)
                {
                    chart.Columns.Add(new ChartColumnEmbedded());
                    result = true;
                }

                chart.Columns[i].parentChart  = chart;
                chart.Columns[i].ScriptColumn = chartScript.Columns[i];

                if (!result)
                {
                    result = chart.Columns[i].IntegrityCheck() != null;
                }
            }

            if (chart.Columns.Count > chartScript.Columns.Count)
            {
                chart.Columns.RemoveRange(chartScript.Columns.Count, chart.Columns.Count - chartScript.Columns.Count);
                result = true;
            }

            if (chart.Parameters.Modified != ModifiedState.Sealed)
            {
                if (chart.Parameters.Select(a => a.Name).OrderBy().SequenceEqual(chartScript.Parameters.Select(a => a.Name).OrderBy()))
                {
                    foreach (var cp in chart.Parameters)
                    {
                        var sp = chartScript.Parameters.FirstEx(a => a.Name == cp.Name);

                        cp.parentChart     = chart;
                        cp.ScriptParameter = sp;
                        //if (cp.PropertyCheck(() => cp.Value).HasText())
                        //    cp.Value = sp.DefaultValue(cp.GetToken());
                    }
                }
                else
                {
                    var byName = chart.Parameters.ToDictionary(a => a.Name);
                    chart.Parameters.Clear();
                    foreach (var sp in chartScript.Parameters)
                    {
                        var cp = byName.TryGetC(sp.Name);

                        if (cp != null)
                        {
                            cp.parentChart     = chart;
                            cp.ScriptParameter = sp;

                            //if (cp.PropertyCheck(() => cp.Value).HasText())
                            //    cp.Value = sp.DefaultValue(cp.GetToken());
                        }
                        else
                        {
                            cp = new ChartParameterEmbedded
                            {
                                Name            = sp.Name,
                                parentChart     = chart,
                                ScriptParameter = sp,
                            };

                            cp.Value = sp.DefaultValue(sp.GetToken(chart));
                        }

                        chart.Parameters.Add(cp);
                    }
                }
            }

            if (chartScript.GroupBy == GroupByChart.Always && chart.GroupResults == false)
            {
                chart.GroupResults = true;
                result             = true;
            }
            else if (chartScript.GroupBy == GroupByChart.Never && chart.GroupResults == true)
            {
                chart.GroupResults = false;
                result             = true;
            }

            return(result);
        }
 public virtual void OnDraw(SKCanvas canvas, SKPoint pos, IChartBase chart)
 {
 }
Beispiel #15
0
 public override void Draw(SKCanvas canvas, SKPoint pos, IChartBase chart)
 {
     new TextLayout().Draw(canvas, text, SKRect.Create(pos.X, pos.Y, 250, 50));
     base.Draw(canvas, pos, chart);
 }
        public virtual SKPoint GetOffsetForDrawingAtPoint(SKPoint pos, SKImageInfo info, IChartBase chart)
        {
            var offset = Offset;

            float width  = info.Width;
            float height = info.Height;

            if (pos.X + offset.X < 0)
            {
                offset.X = -pos.X;
            }
            else if (chart != null && pos.X + width + offset.X > chart.ChartWidth)
            {
                offset.X = chart.ChartWidth - pos.X - width;
            }

            if (pos.Y + offset.Y < 0)
            {
                offset.Y = -pos.Y;
            }
            else if (chart != null && pos.Y + height + offset.Y > chart.ChartHeight)
            {
                offset.Y = chart.ChartHeight - pos.Y - height;
            }

            return(offset);
        }
Beispiel #17
0
 public AnimatedViewPortJob(ViewPortHandler viewPortHandler, float xValue, float yValue, Transformer trans, IChartBase v, float xOrigin, float yOrigin, long duration) :
     base(viewPortHandler, xValue, yValue, trans, v)
 {
     this.xOrigin  = xOrigin;
     this.yOrigin  = yOrigin;
     this.duration = duration;
 }
        public bool IsCompatibleWith(IChartBase chartBase)
        {
            if (GroupBy == GroupByChart.Always && !chartBase.GroupResults)
                return false;

            if (GroupBy == GroupByChart.Never && chartBase.GroupResults)
                return false;

            return Columns.ZipOrDefault(chartBase.Columns, (s, c) =>
            {
                if (s == null)
                    return c.Token == null;

                if (c == null || c.Token == null)
                    return s.IsOptional;

                if (!ChartUtils.IsChartColumnType(c.Token.Token, s.ColumnType))
                    return false;

                if (c.Token.Token is AggregateToken)
                    return !s.IsGroupKey;
                else
                    return s.IsGroupKey || !chartBase.GroupResults; 

            }).All(a => a);
        }
        public static bool SyncronizeColumns(this ChartScriptEntity chartScript, IChartBase chart)
        {
            bool result = false;

            if (chartScript == null)
            {
                result = true;
                chart.Columns.Clear();
            }

            for (int i = 0; i < chartScript.Columns.Count; i++)
            {
                if (chart.Columns.Count <= i)
                {
                    chart.Columns.Add(new ChartColumnEntity());
                    result = true;
                }

                chart.Columns[i].parentChart = chart;
                chart.Columns[i].ScriptColumn = chartScript.Columns[i];
             
                if (!result)
                    result = chart.Columns[i].IntegrityCheck() != null;
            }

            if (chart.Columns.Count > chartScript.Columns.Count)
            {
                chart.Columns.RemoveRange(chartScript.Columns.Count, chart.Columns.Count - chartScript.Columns.Count);
                result = true;
            }

            if (chart.Parameters.Modified != ModifiedState.Sealed)
            {
                if (chart.Parameters.Select(a => a.Name).OrderBy().SequenceEqual(chartScript.Parameters.Select(a => a.Name).OrderBy()))
                {
                    foreach (var cp in chart.Parameters)
                    {
                        var sp = chartScript.Parameters.FirstEx(a => a.Name == cp.Name);

                        cp.parentChart = chart;
                        cp.ScriptParameter = sp;
                        //if (cp.PropertyCheck(() => cp.Value).HasText())
                        //    cp.Value = sp.DefaultValue(cp.GetToken());
                    }
                }
                else
                {
                    var byName = chart.Parameters.ToDictionary(a => a.Name);
                    chart.Parameters.Clear();
                    foreach (var sp in chartScript.Parameters)
                    {
                        var cp = byName.TryGetC(sp.Name);

                        if (cp != null)
                        {
                            cp.parentChart = chart;
                            cp.ScriptParameter = sp;

                            //if (cp.PropertyCheck(() => cp.Value).HasText())
                            //    cp.Value = sp.DefaultValue(cp.GetToken());
                        }
                        else
                        {
                            cp = new ChartParameterEntity
                            {
                                Name = sp.Name,
                                parentChart = chart,
                                ScriptParameter = sp,
                            };

                            cp.Value = sp.DefaultValue(sp.GetToken(chart));
                        }

                        chart.Parameters.Add(cp);
                    }
                }
            }

            if (chartScript.GroupBy == GroupByChart.Always && chart.GroupResults == false)
            {
                chart.GroupResults = true;
                result = true;
            }
            else if (chartScript.GroupBy == GroupByChart.Never && chart.GroupResults == true)
            {
                chart.GroupResults = false;
                result = true;
            }

            return result;
        }
Beispiel #20
0
        public static bool SynchronizeColumns(this ChartScript chartScript, IChartBase chart, PostRetrievingContext?ctx)
        {
            bool result = false;

            for (int i = 0; i < chartScript.Columns.Count; i++)
            {
                if (chart.Columns.Count <= i)
                {
                    chart.Columns.Add(new ChartColumnEmbedded());
                    result = true;
                }

                chart.Columns[i].parentChart  = chart;
                chart.Columns[i].ScriptColumn = chartScript.Columns[i];

                if (!result)
                {
                    result = chart.Columns[i].IntegrityCheck() != null;
                }
            }

            if (chart.Columns.Count > chartScript.Columns.Count)
            {
                chart.Columns.RemoveRange(chartScript.Columns.Count, chart.Columns.Count - chartScript.Columns.Count);
                result = true;
            }

            if (chart.Parameters.Modified != ModifiedState.Sealed)
            {
                var chartScriptParameters = chartScript.AllParameters().ToList();

                if (chart.Parameters.Select(a => a.Name).OrderBy().SequenceEqual(chartScriptParameters.Select(a => a.Name).OrderBy()))
                {
                    foreach (var cp in chart.Parameters)
                    {
                        var sp = chartScriptParameters.FirstEx(a => a.Name == cp.Name);

                        cp.parentChart     = chart;
                        cp.ScriptParameter = sp;

                        //if (cp.PropertyCheck(() => cp.Value).HasText())
                        //    cp.Value = sp.DefaultValue(cp.GetToken());
                    }
                }
                else
                {
                    var byName = chart.Parameters.ToDictionary(a => a.Name);
                    chart.Parameters.Clear();
                    foreach (var sp in chartScriptParameters)
                    {
                        var cp = byName.TryGetC(sp.Name);

                        if (cp != null)
                        {
                            cp.parentChart     = chart;
                            cp.ScriptParameter = sp;
                            ctx?.ForceModifiedState.Add(cp, ModifiedState.SelfModified);
                            //if (cp.PropertyCheck(() => cp.Value).HasText())
                            //    cp.Value = sp.DefaultValue(cp.GetToken());
                        }
                        else
                        {
                            cp = new ChartParameterEmbedded
                            {
                                Name            = sp.Name,
                                parentChart     = chart,
                                ScriptParameter = sp,
                            };

                            cp.Value = sp.ValueDefinition.DefaultValue(sp.GetToken(chart));
                        }

                        chart.Parameters.Add(cp);
                    }
                }
            }

            return(result);
        }
 public AnimatedViewPortJob(ViewPortHandler viewPortHandler, float xValue, float yValue, Transformer trans, IChartBase v, float xOrigin, float yOrigin, long duration) :
     base(viewPortHandler, xValue, yValue, trans, v)
 {
     this.xOrigin = xOrigin;
     this.yOrigin = yOrigin;
     animator = ObjectAnimator.OfFloat(this, "phase", 0f, 1f);
     animator.SetDuration(duration);
     animator.AddUpdateListener(this);
     animator.AddListener(this);
 }