Beispiel #1
0
    void Awake()
    {
        var             xchart   = transform.Find("xchart");
        GridLayoutGroup grid     = xchart.GetComponent <GridLayoutGroup>();
        RectTransform   rect     = transform.GetComponent <RectTransform>();
        var             wid      = rect.sizeDelta.x;
        int             childNum = xchart.childCount;
        float           hig      = grid.padding.top + childNum * (grid.cellSize.y + grid.spacing.y);

        rect.sizeDelta = new Vector2(wid, hig);
        xchart.GetComponent <RectTransform>().sizeDelta = new Vector2(wid, hig);

        chart = xchart.gameObject.GetComponentInChildren <BaseChart>();
    }
Beispiel #2
0
        public static void InitChartData(this BaseChart basechart)
        {
            basechart.Series.Clear();
            string[] arrSeries = { "A", "B", "C", "D" };
            Random   rd        = new Random();

            basechart.Palette = ChartColorPalette.BrightPastel;
            basechart.Titles.Add("Test");
            for (int x = 0; x < arrSeries.Length; x++)
            {
                Series series = basechart.Series.Add(arrSeries[x]);
                series.Points.Add(rd.Next(50));
            }
        }
Beispiel #3
0
        void Awake()
        {
            chart = gameObject.GetComponent <BaseChart>();
            if (chart == null)
            {
                chart = gameObject.AddComponent <BarChart>();
            }
            var serie = chart.GetSerie(0);

            serie.animation.enable = true;
            //自定义每个数据项的渐入延时
            serie.animation.fadeInDelayFunction = CustomFadeInDelay;
            //自定义每个数据项的渐入时长
            serie.animation.fadeInDurationFunction = CustomFadeInDuration;
        }
Beispiel #4
0
        async Task HandleRedraw <TDataSet, TItem, TOptions, TModel>(BaseChart <TDataSet, TItem, TOptions, TModel> chart, params Func <TDataSet>[] getDataSets)
            where TDataSet : ChartDataset <TItem>
            where TOptions : ChartOptions
            where TModel : ChartModel
        {
            await chart.Clear();

            await chart.AddLabel(Labels);

            foreach (var getDataSet in getDataSets)
            {
                await chart.AddDataSet(getDataSet());
            }

            await chart.Update();
        }
Beispiel #5
0
        void Awake()
        {
            chart = gameObject.GetComponent <BaseChart>();
            var serie = chart.GetSerie(0);

            serie.symbol.show = false;
            serie.maxCache    = maxCacheDataNumber;

            var xAxis = chart.GetOrAddChartComponent <XAxis>();

            xAxis.maxCache = maxCacheDataNumber;
            timeNow        = DateTime.Now;
            timeNow        = timeNow.AddSeconds(-maxCacheDataNumber);

            serie.insertDataToHead = insertDataToHead;
            xAxis.insertDataToHead = insertDataToHead;
        }
Beispiel #6
0
        // Button Close Click - Remove the Tab - (or raise an event indicating a "CloseTab" event has occurred)
        void button_close_Click(object sender, RoutedEventArgs e)
        {
            RadTabControl tabControl = (RadTabControl)this.Parent;

            if (Type.Equals(InfoType.Chart))
            {
                Grid      grid  = Content as Grid;
                BaseChart chart = grid.ChildrenOfType <BaseChart>().FirstOrDefault();
                grid.Children.Remove(chart);
            }


            tabControl.Items.Remove(this);

            //if (tabControl.Items.Count == 1)
            //{
            //    RadTabItem item = (RadTabItem)(tabControl.Items[0]);
            //    item.IsSelected = true; // true;
            //}
        }
        internal void Init(BaseChart chart, Serie target, SerializedProperty property, UnityEditor.Editor inspector)
        {
            this.chart        = chart;
            this.serie        = target;
            this.baseProperty = property;
            m_DisplayName     = string.Format("Serie {0}: {1}", serie.index, serie.GetType().Name);
            //m_Inspector = inspector;
            showProperty = baseProperty.FindPropertyRelative("m_Show");
            if (showProperty == null)
            {
                showProperty = baseProperty.FindPropertyRelative("m_Enable");
            }
            OnEnable();

            if (serie.GetType().IsDefined(typeof(CoordOptionsAttribute), false))
            {
                var attribute = serie.GetType().GetAttribute <CoordOptionsAttribute>();
                m_CoordOptionsDic   = new Dictionary <string, Type>();
                m_CoordOptionsNames = new List <string>();
                if (attribute.type0 != null)
                {
                    m_CoordOptionsDic[attribute.type0.Name] = attribute.type0;
                    m_CoordOptionsNames.Add(attribute.type0.Name);
                }
                if (attribute.type1 != null)
                {
                    m_CoordOptionsDic[attribute.type1.Name] = attribute.type1;
                    m_CoordOptionsNames.Add(attribute.type1.Name);
                }
                if (attribute.type2 != null)
                {
                    m_CoordOptionsDic[attribute.type2.Name] = attribute.type2;
                    m_CoordOptionsNames.Add(attribute.type2.Name);
                }
                if (attribute.type3 != null)
                {
                    m_CoordOptionsDic[attribute.type3.Name] = attribute.type3;
                    m_CoordOptionsNames.Add(attribute.type3.Name);
                }
            }
        }
Beispiel #8
0
        void AddChart()
        {
            chart = gameObject.GetComponent <BaseChart>();
            if (chart == null)
            {
                chart = gameObject.AddComponent <LineChart>();
                chart.Init();
                chart.SetSize(1200, 600);
            }
            var title = chart.GetOrAddChartComponent <Title>();

            title.text    = "Simple LineChart";
            title.subText = "normal line";

            var tooltip = chart.GetOrAddChartComponent <Tooltip>();

            tooltip.show = true;

            var legend = chart.GetOrAddChartComponent <Legend>();

            legend.show = false;

            var xAxis = chart.GetOrAddChartComponent <XAxis>();

            xAxis.splitNumber = 10;
            xAxis.boundaryGap = true;
            xAxis.type        = Axis.AxisType.Category;

            var yAxis = chart.GetOrAddChartComponent <YAxis>();

            yAxis.type = Axis.AxisType.Value;

            chart.RemoveData();
            chart.AddSerie <Line>("line");

            for (int i = 0; i < 5; i++)
            {
                chart.AddXAxisData("x" + i);
                chart.AddData(0, Random.Range(10, 20));
            }
        }
Beispiel #9
0
        public void Init(BaseChart chart, SerializedObject serializedObject, List <SerializedProperty> componentProps)
        {
            Assert.IsNotNull(chart);

            this.chart           = chart;
            m_ComponentsProperty = componentProps;

            Assert.IsNotNull(m_ComponentsProperty);

            m_Editors     = new List <MainComponentBaseEditor>();
            m_EditorTypes = new Dictionary <Type, Type>();

            var editorTypes = RuntimeUtil.GetAllTypesDerivedFrom <MainComponentBaseEditor>()
                              .Where(t => t.IsDefined(typeof(ComponentEditorAttribute), false) && !t.IsAbstract);

            foreach (var editorType in editorTypes)
            {
                var attribute = editorType.GetAttribute <ComponentEditorAttribute>();
                m_EditorTypes.Add(attribute.componentType, editorType);
            }

            RefreshEditors();
        }
Beispiel #10
0
 void Awake()
 {
     xchart = this.gameObject.transform;
     chart  = xchart.gameObject.GetComponentInChildren <BaseChart>();
 }
 void OnScroll(BaseChart chart, PointerEventData eventData)
 {
     //Debug.LogError("scroll:" + chart);
 }
 void OnPointerClick(BaseChart chart, PointerEventData eventData)
 {
     //Debug.LogError("click:" + chart);
 }
 void OnPointerUp(BaseChart chart, PointerEventData eventData)
 {
     //Debug.LogError("up:" + chart);
 }
 void OnPointerDown(BaseChart chart, PointerEventData eventData)
 {
     //Debug.LogError("down:" + chart);
 }
 void OnPointerExit(BaseChart chart, PointerEventData eventData)
 {
     //Debug.LogError("exit:" + chart);
 }
Beispiel #16
0
 public virtual void Init(BaseChart c)
 {
     chart = c;
     GeneratePlot();
 }
 void Awake()
 {
     chart = gameObject.GetComponent <BaseChart>();
 }
Beispiel #18
0
 public WidgetCardChartBar()
 {
     Chart    = new BaseChart();
     Title    = new WidgetCardChartBarTitle();
     IsLoaded = false;
 }
        private void UpdateTemplate()
        {
            var stackPanel = new StackPanel {
                Orientation = Orientation.Vertical
            };

            Content = stackPanel;

            var titleText = new TextBlock
            {
                Style        = _pageSubHeaderTextStyle,
                TextWrapping = TextWrapping.Wrap,
            };

            stackPanel.Children.Add(titleText);
            var hasTitle = PopupInfo != null && PopupInfo.Title != null && PopupInfo.Title.Trim().Length > 0;

            if (hasTitle)
            {
                titleText.SetBinding(InlineCollectionProperty, new Binding
                {
                    Path               = new PropertyPath("Attributes"),
                    Source             = this,
                    Converter          = new StringFormatToInlineCollectionConverter(),
                    ConverterParameter = PopupInfo.Title
                });
            }
            if (PopupInfo != null && PopupInfo.Description != null && PopupInfo.Description.Trim().Length > 0)
            {
                if (!hasTitle)
                {
                    hasTitle = true;
                    titleText.SetBinding(InlineCollectionProperty, new Binding
                    {
                        Path               = new PropertyPath("Attributes"),
                        Source             = this,
                        Converter          = new StringFormatToInlineCollectionConverter(),
                        ConverterParameter = PopupInfo.Description
                    });
                }
                var desc = new RichTextBlock
                {
                    FontSize   = _controlContentThemeFontSize,
                    FontFamily = _contentControlThemeFontFamily
                };
                stackPanel.Children.Add(desc);

                var p = new Paragraph();
                desc.Blocks.Add(p);

                BindingOperations.SetBinding(p, HtmlToTextConverter.HtmlToInlinesProperty, new Binding
                {
                    Path               = new PropertyPath("Attributes"),
                    Source             = this,
                    Converter          = new HtmlToTextConverter(),
                    ConverterParameter = PopupInfo.Description
                });
            }
            else //Show attribute list
            {
                List <FieldInfo> displayFields = null;
                if (PopupInfo != null && PopupInfo.FieldInfos != null)
                {
                    displayFields = new List <FieldInfo>(PopupInfo.FieldInfos.Where(a => a.IsVisible));
                }
                if (displayFields == null)
                {
                    return;
                }
                var attributes = Attributes as IDictionary <string, object>;
                foreach (var item in displayFields)
                {
                    var sp = new StackPanel();
                    stackPanel.Children.Add(sp);
                    var l = new TextBlock
                    {
                        Style        = _baselineTextStyle,
                        Margin       = new Thickness(0, 10, 0, 0),
                        Text         = item.Label ?? item.FieldName,
                        Foreground   = new SolidColorBrush(Colors.DarkGray),
                        TextWrapping = TextWrapping.Wrap,
                        TextTrimming = TextTrimming.WordEllipsis
                    };
                    sp.Children.Add(l);
                    if (!hasTitle)
                    {
                        hasTitle = true;
                        titleText.SetBinding(InlineCollectionProperty, new Binding
                        {
                            Path   = new PropertyPath(string.Format("Attributes[{0}]", item.FieldName)),
                            Source = this
                        });
                    }
                    var useHyperlink = attributes != null && attributes.ContainsKey(item.FieldName) &&
                                       attributes[item.FieldName] is string && ((string)attributes[item.FieldName]).StartsWith("http");
                    if (useHyperlink || string.Equals("url", item.FieldName, StringComparison.OrdinalIgnoreCase))
                    {
                        var hyperlink = new HyperlinkButton();
                        sp.Children.Add(hyperlink);
                        hyperlink.SetBinding(HyperlinkButton.NavigateUriProperty,
                                             new Binding
                        {
                            Path   = new PropertyPath(string.Format("Attributes[{0}]", item.FieldName)),
                            Source = this
                        });
                        hyperlink.SetBinding(ContentProperty,
                                             new Binding
                        {
                            Path   = new PropertyPath(string.Format("Attributes[{0}]", item.FieldName)),
                            Source = this
                        });
                        hyperlink.Template = (ControlTemplate)XamlReader.Load(
                            "<ControlTemplate TargetType='HyperlinkButton' xmlns='http://schemas.microsoft.com/client/2007' >" +
                            "<TextBlock Text='{TemplateBinding Content}' Padding='0' Margin='0' RenderTransformOrigin='0.5,0.5' TextWrapping='Wrap' TextTrimming ='WordEllipsis'>" +
                            "<TextBlock.RenderTransform>" +
                            "<CompositeTransform TranslateY='5' />" +
                            "</TextBlock.RenderTransform>" +
                            "</TextBlock>" +
                            "</ControlTemplate>");
                        hyperlink.FontFamily = new FontFamily("Segoe UI Light");
                        hyperlink.FontWeight = FontWeights.Normal;
                        hyperlink.Margin     = new Thickness(0);
                        hyperlink.Padding    = new Thickness(0);
                    }
                    else
                    {
                        var t = new TextBlock
                        {
                            Style        = _baselineTextStyle,
                            Margin       = new Thickness(0, 10, 0, 0),
                            TextWrapping = TextWrapping.Wrap,
                            TextTrimming = TextTrimming.WordEllipsis
                        };
                        sp.Children.Add(t);
                        t.SetBinding(TextBlock.TextProperty, new Binding
                        {
                            Path   = new PropertyPath(string.Format("Attributes[{0}]", item.FieldName)),
                            Source = this
                        });
                    }
                }
            }
            if (PopupInfo != null && PopupInfo.MediaInfos != null)
            {
                foreach (var item in PopupInfo.MediaInfos)
                {
                    if (!string.IsNullOrEmpty(item.Title))
                    {
                        var mediaTitle = new TextBlock
                        {
                            Style        = _baselineTextStyle,
                            Margin       = new Thickness(0, 10, 0, 0),
                            FontWeight   = FontWeights.Bold,
                            TextWrapping = TextWrapping.Wrap,
                            TextTrimming = TextTrimming.WordEllipsis
                        };
                        stackPanel.Children.Add(mediaTitle);
                        if (!hasTitle)
                        {
                            hasTitle = true;
                            titleText.SetBinding(InlineCollectionProperty, new Binding
                            {
                                Path               = new PropertyPath("Attributes"),
                                Source             = this,
                                Converter          = new StringFormatToInlineCollectionConverter(),
                                ConverterParameter = item.Title
                            });
                        }
                        mediaTitle.SetBinding(TextBlock.TextProperty, new Binding
                        {
                            Path               = new PropertyPath("Attributes"),
                            Source             = this,
                            Converter          = new StringFormatToStringConverter(),
                            ConverterParameter = item.Title
                        });
                    }
                    if (!string.IsNullOrEmpty(item.Caption))
                    {
                        var mediaCaption = new TextBlock
                        {
                            Style        = _baselineTextStyle,
                            Margin       = new Thickness(0, 10, 0, 0),
                            FontStyle    = FontStyle.Italic,
                            TextWrapping = TextWrapping.Wrap,
                            TextTrimming = TextTrimming.WordEllipsis
                        };
                        stackPanel.Children.Add(mediaCaption);
                        if (!hasTitle)
                        {
                            hasTitle = true;
                            titleText.SetBinding(InlineCollectionProperty, new Binding
                            {
                                Path               = new PropertyPath("Attributes"),
                                Source             = this,
                                Converter          = new StringFormatToInlineCollectionConverter(),
                                ConverterParameter = item.Caption
                            });
                        }
                        mediaCaption.SetBinding(TextBlock.TextProperty, new Binding
                        {
                            Path               = new PropertyPath("Attributes"),
                            Source             = this,
                            Converter          = new StringFormatToStringConverter(),
                            ConverterParameter = item.Caption
                        });
                    }

                    IEnumerable <KeyValuePair <string, string> > fieldMappings = null;
                    if (PopupInfo != null && PopupInfo.FieldInfos != null)
                    {
                        fieldMappings = from f in PopupInfo.FieldInfos
                                        select(new KeyValuePair <string, string>(f.FieldName, f.Label ?? f.FieldName));
                    }
                    BaseChart chart = null;
                    switch (item.Type)
                    {
                    case MediaType.Image:
                        var imageGrid = new Grid();
                        stackPanel.Children.Add(imageGrid);
                        if (!string.IsNullOrEmpty(item.Value.SourceUrl))
                        {
                            var image = new Image
                            {
                                Margin  = new Thickness(0, 10, 0, 0),
                                Width   = 200d,
                                Height  = 200d,
                                Stretch = Stretch.UniformToFill
                            };
                            imageGrid.Children.Add(image);
                            image.SetBinding(Image.SourceProperty, new Binding
                            {
                                Path               = new PropertyPath("Attributes"),
                                Source             = this,
                                Converter          = new StringFormatToBitmapSourceConverter(),
                                ConverterParameter = item.Value.SourceUrl
                            });
                        }
                        if (!string.IsNullOrEmpty(item.Value.LinkUrl))
                        {
                            var hyperlinkButton = new HyperlinkButton
                            {
                                Margin = new Thickness(0, 10, 0, 0),
                                Width  = 200d,
                                Height = 200d
                            };
                            imageGrid.Children.Add(hyperlinkButton);
                            hyperlinkButton.SetBinding(HyperlinkButton.NavigateUriProperty, new Binding
                            {
                                Path               = new PropertyPath("Attributes"),
                                Source             = this,
                                Converter          = new StringFormatToUriConverter(),
                                ConverterParameter = item.Value.LinkUrl
                            });
                        }
                        break;

                    case MediaType.BarChart:
                        chart = new BarChart();
                        break;

                    case MediaType.ColumnChart:
                        chart = new ColumnChart();
                        break;

                    case MediaType.LineChart:
                        chart = new LineChart();
                        break;

                    case MediaType.PieChart:
                        //string normalizeField = item.Value.NormalizeField;
                        chart = new PieChart();
                        break;
                    }
                    if (chart != null)
                    {
                        var fieldString    = string.Join(",", item.Value.Fields);
                        var normalizeField = item.Value.NormalizeField;
                        if (!string.IsNullOrEmpty(normalizeField) && !normalizeField.Equals("null"))
                        {
                            fieldString += BaseChart.NormalizeSeparator + normalizeField;
                        }
                        chart.Margin   = new Thickness(0, 10, 0, 0);
                        chart.Fields   = fieldString;
                        chart.Height   = 200;
                        chart.Width    = 200;
                        chart.FontSize = 10d;
                        var keyValuePairs = fieldMappings as KeyValuePair <string, string>[] ?? fieldMappings.ToArray();
                        if (keyValuePairs.Any())
                        {
                            chart.KeyToLabelDictionary = new ResourceDictionary();
                            foreach (var pair in keyValuePairs)
                            {
                                chart.KeyToLabelDictionary[pair.Key] = pair.Value;
                            }
                        }
                        stackPanel.Children.Add(chart);
                        chart.SetBinding(DataContextProperty, new Binding
                        {
                            Path   = new PropertyPath("Attributes"),
                            Source = this,
                        });
                    }
                }
            }
        }
Beispiel #20
0
 public FileFeed(BaseChart chart)
 {
     this.chart = chart;
 }
Beispiel #21
0
 public LiveFeed(BaseChart chart)
 {
     this.chart = chart;
 }
 public static void SetChartPosition(BaseChart chart)
 {
     chart.transform.position = new Vector2(xPos, yPos);
     xPos += 500;
 }