Пример #1
0
        private void SetConstline()
        {
            NAxis axis = m_Chart.Axis(StandardAxis.PrimaryY);

            // add a constline if necessary
            if (axis.ConstLines.Count == 0)
            {
                axis.ConstLines.Add();
            }

            // the line series won't be used
            m_Line.Visible = false;

            // calc the sum of the elements
            NDataSeriesDouble ds = m_FuncCalculator.Calculate();

            // add a new constline
            NAxisConstLine cl = (NAxisConstLine)axis.ConstLines[0];

            cl.StrokeStyle.Width = new NLength(2, NGraphicsUnit.Pixel);
            cl.StrokeStyle.Color = Color.Red;
            cl.Value             = (double)ds.GetValueForIndex(0);

            m_LabelSum.Text = cl.Value.ToString();

            // set proper scale for the axis, so that it includes the constline
            if (cl.Value >= 0)
            {
                // if the sum is positive - compare it to the largest value
                m_FuncCalculator.Expression = "MAX(values)";
                ds = m_FuncCalculator.Calculate();

                double dMax = (double)ds.GetValueForIndex(0);

                if (cl.Value > dMax)
                {
                    dMax = cl.Value;
                }

                axis.View = new NRangeAxisView(new NRange1DD(0, dMax), false, true);
            }
            else
            {
                // if the sum is negative - compare it to the smallest value
                m_FuncCalculator.Expression = "MIN(values)";
                ds = m_FuncCalculator.Calculate();

                double dMin = (double)ds.GetValueForIndex(0);

                if (cl.Value < dMin)
                {
                    dMin = cl.Value;
                }

                axis.View = new NRangeAxisView(new NRange1DD(dMin, 0), true, false);
            }
        }
        private void CalcFunction()
        {
            NDataSeriesDouble ds = m_FuncCalculator.Calculate();

            if (ds == null)
            {
                return;
            }

            m_Chart.Axis(StandardAxis.PrimaryY).ConstLines.Clear();
            m_Line.Visible = false;

            if (m_GroupingCombo.SelectedIndex == 0)
            {
                // add a constline if there is no grouping
                NAxisConstLine cl = m_Chart.Axis(StandardAxis.PrimaryY).ConstLines.Add();
                cl.StrokeStyle.Width = new NLength(2, NGraphicsUnit.Pixel);
                cl.StrokeStyle.Color = Color.Red;
                cl.Value             = (double)ds.GetValueForIndex(0);
            }
            else
            {
                m_Line.Visible = true;
                m_Line.Values  = ds;
                m_Line.Values.ValueFormatter = new NNumericValueFormatter("0.00");
            }

            nChartControl1.Refresh();
        }
Пример #3
0
        private void CalculateFunction()
        {
            NAxisConstLine    cl = (NAxisConstLine)m_Chart.Axis(StandardAxis.PrimaryY).ConstLines[0];
            NDataSeriesDouble ds = m_FuncCalculator.Calculate();

            cl.Value = (double)ds.GetValueForIndex(0);

            m_LabelResult.Text = cl.Value.ToString();
        }
        private void SetConstline(NDataSeriesDouble ds)
        {
            NAxis axis = m_Chart.Axis(StandardAxis.PrimaryY);

            // add a constline if necessary
            if (axis.ConstLines.Count == 0)
            {
                axis.ConstLines.Add();
            }

            // the line series won't be used
            m_Line.Visible = false;

            // add a new constline
            NAxisConstLine cl = (NAxisConstLine)axis.ConstLines[0];

            cl.StrokeStyle.Width = new NLength(3, NGraphicsUnit.Pixel);
            cl.StrokeStyle.Color = Color.Green;
            cl.Value             = (double)ds.GetValueForIndex(0);

            string text = cl.Value.ToString();

            if (text.Length > 7)
            {
                text = text.Substring(0, 7);
            }

/*			NAxisCustomLabel axisLabel = axis.CustomLabels.Add();
 *                      axisLabel.Offset = 3;
 *                      axisLabel.TextStyle.BackplaneStyle.Visible = true;
 *                      axisLabel.Angle = 180;
 *                      axisLabel.Text = text;
 *                      axisLabel.Value = cl.Value;*/

            // set proper scale for the axis, so that it includes the constline
            NDataSeriesSubset subset = new NDataSeriesSubset();

            subset.AddRange(0, ds.Count - 1);

            double max1 = m_Line1.Values.Evaluate("MAX", subset);
            double min1 = m_Line1.Values.Evaluate("MIN", subset);

            double max2 = m_Line2.Values.Evaluate("MAX", subset);
            double min2 = m_Line2.Values.Evaluate("MIN", subset);

            if (max1 < max2)
            {
                max1 = max2;
            }

            if (min1 > min2)
            {
                min1 = min2;
            }

            if (cl.Value > max1)
            {
                axis.View = new NRangeAxisView(new NRange1DD(double.MinValue, cl.Value), false, true);
            }
            else if (cl.Value < min1)
            {
                axis.View = new NRangeAxisView(new NRange1DD(cl.Value, double.MaxValue), true, false);
            }
        }