예제 #1
0
 public static void AddPointToCategoryWithLabelRealtime(GraphChartBase chart, string category, double x, DateTime y, double slideTime = 0, double pointSize = -1, string xLabel = null, string yLabel = null)
 {
     AddPointToCategoryWithLabelRealtime(chart, category, x, ChartDateUtility.DateToValue(y), slideTime, pointSize, xLabel, yLabel);
 }
예제 #2
0
        private void DrawDivisions(double scrollOffset, AnyChart parent, Transform parentTransform, ChartDivisionInfo info, IChartMesh mesh, int group, ChartOrientation orientation, double gap, bool oppositeSide, double mainGap)
        {
            //scrollOffset = -scrollOffset;
            double        parentSize = (orientation == ChartOrientation.Vertical) ? ((IInternalUse)parent).InternalTotalHeight : ((IInternalUse)parent).InternalTotalWidth;
            DoubleVector3 startPosition, lengthDirection, advanceDirection;

            GetDirectionVectors(parent, info, orientation, 0f, oppositeSide, out startPosition, out lengthDirection, out advanceDirection);
            double markDepth  = ChartCommon.GetAutoDepth(parent, orientation, info);
            double length     = ChartCommon.GetAutoLength(parent, orientation, info);
            double backLength = (orientation == ChartOrientation.Vertical) ? ((IInternalUse)parent).InternalTotalWidth : ((IInternalUse)parent).InternalTotalHeight;

            if (info.MarkBackLength.Automatic == false)
            {
                backLength = info.MarkBackLength.Value;
            }

            double totaluv = Math.Abs(length);

            if (backLength != 0 && markDepth > 0)
            {
                totaluv += Math.Abs(backLength) + Math.Abs(markDepth);
            }

            DoubleVector3 halfThickness = advanceDirection * (info.MarkThickness * 0.5f);
            // if (scrollOffset != 0f)
            //     last--;

            bool   hasValues = ((IInternalUse)parent).InternalHasValues(this);
            double maxValue  = ((IInternalUse)parent).InternalMaxValue(this);
            double minValue  = ((IInternalUse)parent).InternalMinValue(this);
            double range     = maxValue - minValue;

            float AutoAxisDepth = Depth.Value;

//            float scrollFactor = (scrollOffset / (float)(maxValue - minValue));
            //scrollOffset = scrollFactor * parentSize;

            if (Depth.Automatic)
            {
                AutoAxisDepth = (float)((((IInternalUse)parent).InternalTotalDepth) - markDepth);
            }

            double startValue = (scrollOffset + minValue);
            double endValue   = (scrollOffset + maxValue) + double.Epsilon;
            Func <double, double> ValueToPosition = x => ((x - startValue) / range) * parentSize;
            double fraction     = gap - (scrollOffset - Math.Floor((scrollOffset / gap) - double.Epsilon) * gap);
            double mainfraction = -1f;
            double currentMain  = 0f;

            if (mainGap > 0f)
            {
                mainfraction = mainGap - (scrollOffset - Math.Floor((scrollOffset / mainGap) - double.Epsilon) * mainGap);
                currentMain  = (scrollOffset + minValue + mainfraction);
            }

            int i = 0;

            mTmpToRemove.Clear();
            double startRange = startValue + fraction;

            foreach (double key in mFormats.Keys)
            {
                if (key > endValue || key < startRange)
                {
                    mTmpToRemove.Add(key);
                }
            }
            for (int k = 0; k < mTmpToRemove.Count; k++)
            {
                mFormats.Remove(mTmpToRemove[k]);
            }
            for (double current = startRange; current <= endValue; current += gap)
            {
                ++i;
                if (i > 3000)
                {
                    break;
                }

                if (mainGap > 0.0)
                {
                    if (Math.Abs(current - currentMain) < 0.00001)
                    {
                        currentMain += mainGap;
                        continue;
                    }
                    if (current > currentMain)
                    {
                        currentMain += mainGap;
                    }
                }

                double        offset = ValueToPosition(current);
                DoubleVector3 start  = startPosition + advanceDirection * offset;
                DoubleVector3 size   = halfThickness + length * lengthDirection;
                start -= halfThickness;
                //size += halfThickness;
                float uvoffset = 0f;

                Rect r = ChartCommon.FixRect(new Rect((float)start.x, (float)start.y, (float)size.x, (float)size.y));

                SetMeshUv(mesh, (float)(-length / totaluv), uvoffset);
                uvoffset += Math.Abs(mesh.Length);

                mesh.AddXYRect(r, group, AutoAxisDepth);
                if (hasValues)
                {
                    double val    = Math.Round(current * 1000.0) / 1000.0;
                    string toSet  = "";
                    int    keyVal = (int)Math.Round(val);
                    var    dic    = (orientation == ChartOrientation.Horizontal) ? parent.HorizontalValueToStringMap : parent.VerticalValueToStringMap;
                    if (!(Math.Abs(val - keyVal) < 0.001 && dic.TryGetValue(keyVal, out toSet)))
                    {
                        if (mFormats.TryGetValue(val, out toSet) == false)
                        {
                            if (format == AxisFormat.Number)
                            {
                                toSet = ChartAdancedSettings.Instance.FormatFractionDigits(info.FractionDigits, val);
                            }
                            else
                            {
                                DateTime date = ChartDateUtility.ValueToDate(val);
                                if (format == AxisFormat.DateTime)
                                {
                                    toSet = ChartDateUtility.DateToDateTimeString(date);
                                }
                                else
                                {
                                    if (format == AxisFormat.Date)
                                    {
                                        toSet = ChartDateUtility.DateToDateString(date);
                                    }
                                    else
                                    {
                                        toSet = ChartDateUtility.DateToTimeString(date);
                                    }
                                }
                            }
                            toSet         = info.TextPrefix + toSet + info.TextSuffix;
                            mFormats[val] = toSet;
                        }
                    }
                    else
                    {
                        toSet = info.TextPrefix + toSet + info.TextSuffix;
                    }


                    DoubleVector3 textPos = new DoubleVector3(start.x, start.y);
                    textPos += lengthDirection * info.TextSeperation;
                    TextData userData = new TextData();
                    userData.interp         = (float)(offset / parentSize);
                    userData.info           = info;
                    userData.fractionDigits = info.FractionDigits;
                    mesh.AddText(parent, info.TextPrefab, parentTransform, info.FontSize, info.FontSharpness, toSet, (float)textPos.x, (float)textPos.y, AutoAxisDepth + info.TextDepth, 0f, userData);
                }

                if (markDepth > 0)
                {
                    if (orientation == ChartOrientation.Horizontal)
                    {
                        SetMeshUv(mesh, (float)(markDepth / totaluv), uvoffset);
                        r = ChartCommon.FixRect(new Rect((float)start.x, AutoAxisDepth, (float)size.x, (float)markDepth));
                        mesh.AddXZRect(r, group, (float)start.y);
                    }
                    else
                    {
                        SetMeshUv(mesh, (float)(-markDepth / totaluv), uvoffset);
                        r = ChartCommon.FixRect(new Rect((float)start.y, AutoAxisDepth, (float)size.y, (float)markDepth));
                        mesh.AddYZRect(r, group, (float)start.x);
                    }

                    uvoffset += Math.Abs(mesh.Length);

                    if (backLength != 0)
                    {
                        SetMeshUv(mesh, (float)(backLength / totaluv), uvoffset);
                        uvoffset += Math.Abs(mesh.Length);
                        DoubleVector3 backSize = halfThickness + backLength * lengthDirection;
                        Rect          backR    = ChartCommon.FixRect(new Rect((float)start.x, (float)start.y, (float)backSize.x, (float)backSize.y));
                        mesh.AddXYRect(backR, group, (float)(AutoAxisDepth + markDepth));
                    }
                }
            }
            //   Debug.Log("start");
            //   Debug.Log(mFormats.Count);
            //   Debug.Log(cached);
        }
예제 #3
0
 public static void AddPointToCategoryWithLabel(GraphChartBase chart, string category, DateTime x, DateTime y, double pointSize = -1, string xLabel = null, string yLabel = null)
 {
     AddPointToCategoryWithLabel(chart, category, ChartDateUtility.DateToValue(x), ChartDateUtility.DateToValue(y), pointSize, xLabel, yLabel);
 }
예제 #4
0
 public void SetCurveInitialPoint(string category, double x, DateTime y, double pointSize = -1f)
 {
     SetCurveInitialPoint(category, x, ChartDateUtility.DateToValue(y), pointSize);
 }
예제 #5
0
        public void AddPointToCategoryRealtime(string category, double x, DateTime y, double slideTime = 0f, double pointSize = -1f)
        {
            double yVal = ChartDateUtility.DateToValue(y);

            AddPointToCategoryRealtime(category, x, (double)yVal, slideTime, pointSize);
        }
예제 #6
0
        /// <summary>
        /// adds a point to the category. having the point y value as date
        /// </summary>
        /// <param name="category"></param>
        /// <param name="x"></param>
        /// <param name="y"></param>
        public void AddPointToCategory(string category, double x, DateTime y, double pointSize = -1f)
        {
            double yVal = ChartDateUtility.DateToValue(y);

            AddPointToCategory(category, x, (double)yVal, pointSize);
        }
예제 #7
0
        /// <summary>
        /// adds a point to the category. having the point x value as date
        /// <param name="category"></param>
        /// <param name="x"></param>
        /// <param name="y"></param>
        public void AddPointToCategory(string category, DateTime x, double y, double pointSize = -1f)
        {
            double xVal = ChartDateUtility.DateToValue(x);

            AddPointToCategory(category, (double)xVal, y, pointSize);
        }
 /// <summary>
 /// transform a point from axis units into world space. returns true on success and false on failure (failure should never happen for this implementation)
 /// </summary>
 /// <param name="result"> the resulting world space point</param>
 /// <param name="x">x coordinate in axis units</param>
 /// <param name="y">y coodinate in axis units</param>
 /// <param name="category">for 3d chart specifing a catgory will return a point with the proper depth setting</param>
 /// <returns></returns>
 public bool PointToWorldSpace(out Vector3 result, DateTime x, DateTime y, string category = null)
 {
     return(PointToWorldSpace(out result, ChartDateUtility.DateToValue(x), ChartDateUtility.DateToValue(y), category));
 }