示例#1
0
        public static Chart Configure(
            ObservableCollection <TechnologicalConditionDTO> itemsDataSourceDTO,
            ObservableCollection <TimeCharacteristicDTO> itemsTimeCharacteristicDTO)
        {
            var series           = GetSeries(itemsDataSourceDTO, itemsTimeCharacteristicDTO);
            var seriesCollection = new SeriesCollection();

            seriesCollection.AddRange(series);

            var axisX = new AxesCollection();

            axisX.Add(new Axis {
                Title = "Продолжительность", MinValue = 0, Position = AxisPosition.RightTop
            });

            var labels = itemsDataSourceDTO.Select((p, i) => (++i).ToString());

            var axisY = new AxesCollection();

            axisY.Add(new Axis {
                Title = "Работа", Labels = labels.ToList()
            });

            return(new CartesianChart
            {
                AxisX = axisX,
                AxisY = axisY,
                Series = seriesCollection
            });
        }
示例#2
0
        /// <summary>
        /// Creates axises for charts.
        /// </summary>
        /// <param name="x">Values for the X axis</param>
        /// <param name="xtitle">Title of the X axis</param>
        /// <param name="y">Values for the Y axis</param>
        /// <param name="ytitle">Title for the Y axis</param>
        /// <param name="chart">Chart to apply the axises to</param>
        /// <param name="Collection">Values collection</param>
        /// <param name="xStep">How many steps on the x axis</param>
        /// <param name="rotation">Labels roatation on the X axis</param>
        private void CreateAxis(IList <string> x, string xtitle, IList <string> y, string ytitle, CartesianChart chart, SeriesCollection Collection, double xStep = 0.0, double yStep = 0.0, int rotation = 0)
        {
            Axis axisx = new Axis();

            axisx.Labels = x;
            axisx.Title  = xtitle;
            if (xStep > 0)
            {
                axisx.Separator.Step = xStep;
            }
            axisx.LabelsRotation = rotation;

            Axis axisy = new Axis();

            axisy.Labels = y;
            axisy.Title  = ytitle;

            if (yStep > 0)
            {
                axisy.Separator.Step = yStep;
            }

            AxesCollection ax = new AxesCollection();
            AxesCollection ay = new AxesCollection();

            ax.Add(axisx);
            ay.Add(axisy);

            chart.Series      = Collection;
            chart.AxisX       = ax;
            chart.AxisY       = ay;
            chart.DataContext = this;
        }
        private void ShowCartesian()
        {
            SeriesCollection sc = lvc_cartesian_chart.Series;
            AxesCollection   ac = lvc_cartesian_chart.AxisX;

            AxesCollection ay    = lvc_cartesian_chart.AxisY;
            Axis           axisY = new Axis();

            ay.Add(axisY);

            App app = (App)Application.Current;

            MemberCollection     members = app.MembersViewModel.Members;
            ChartValues <double> values  = new ChartValues <double>();
            Axis axis = new Axis();

            axis.Title    = "X title";
            axis.MinWidth = 50;
            ColumnSeries columnSeries = new ColumnSeries {
                Title  = "Cartesian",
                Values = values,
            };

            //string[] labelValues = new string[members.Count];
            List <string> labelValues = new List <string>();

            foreach (Member member in members)
            {
                values.Add(member.BindInsto);
                labelValues.Add(member.BindName);
            }
            sc.Add(columnSeries);
            axis.Labels   = labelValues;
            axis.Position = AxisPosition.LeftBottom;
            //axis.SetRange(0,2);
            //axis.MinValue = 0;
            //axis.MaxValue = 3;
            axis.IsMerged  = true;
            axis.Separator = new Separator()
            {
                Step = 1
            };

            Formatter = value => value.ToString("N");
            //axis.LabelFormatter = Formatter;


            ac.Add(axis);
        }
示例#4
0
        private void UiButtonUpdate_Click(object sender, RoutedEventArgs e)
        {
            List <string>    units  = new List <string>();
            SeriesCollection charts = new SeriesCollection();

            foreach (var chartData in chartDatas)
            {
                if (chartData.IsChecked)
                {
                    var i = units.FindIndex(x => x.Equals(chartData.Value.Units));
                    if (i == -1)
                    {
                        units.Add(chartData.Value.Units);
                        i = units.Count - 1;
                    }
                    var chart = new GLineSeries()
                    {
                        Values         = new ChartValues <float>(chartData.Value.Data.Select(x => x.Item2).ToList()),
                        DataLabels     = false,
                        LineSmoothness = 0,
                        ScalesYAt      = i,
                    };
                    charts.Add(chart);
                }
            }
            uiChartControl.uiChart.Series = charts;

            AxesCollection axes       = new AxesCollection();
            AxisPosition   pos        = AxisPosition.LeftBottom;
            int            colorIndex = 0;

            foreach (var unit in units)
            {
                axes.Add(new Axis
                {
                    Title      = unit,
                    Position   = pos,
                    ShowLabels = true,
                    Foreground = new SolidColorBrush(CartesianChart.Colors[colorIndex]),
                });
                if (pos == AxisPosition.LeftBottom)
                {
                    pos = AxisPosition.RightTop;
                }
                colorIndex++;
            }
            uiChartControl.uiChart.AxisY = axes;
        }
        public LineChartControl(List <GraphableSeries> values)
        {
            InitializeComponent();

            SeriesCollection = new SeriesCollection();
            YFormatter       = new AxesCollection();
            XFormatter       = new AxesCollection();

            YFormatter.Add(new Axis
            {
                IsMerged  = true,
                Separator = new Separator
                {
                    Step      = 1,
                    IsEnabled = true
                }
            });

            XFormatter.Add(new Axis
            {
                IsMerged  = true,
                Separator = new Separator
                {
                    Step      = 1,
                    IsEnabled = true
                }
            });

            foreach (GraphableSeries graphableSeries in values)
            {
                SeriesCollection.Add(
                    new LineSeries
                {
                    Title         = graphableSeries.Title,
                    Values        = graphableSeries.Values,
                    PointGeometry = null
                });
            }


            Chart.LegendLocation = LegendLocation.Bottom;
            DataContext          = this;
        }