Ejemplo n.º 1
0
        private void Chart1_Customize(object sender, EventArgs e)
        {
            //make the X-axis show up with days, hours, minutes, seconds properly.
            //this is not very well documented anywhere but copied from an untraceable blog article.
            CustomLabelsCollection xAxisLabels = ((Chart)sender).ChartAreas[0].AxisX.CustomLabels;

            for (int cnt = 0; cnt < xAxisLabels.Count; cnt++)
            {
                TimeSpan ts = TimeSpan.FromSeconds(double.Parse(xAxisLabels[cnt].Text));
                if (ts.Days > 0)
                {
                    xAxisLabels[cnt].Text = ts.Days.ToString("00") + ":" + ts.Hours.ToString("00") + ":" + ts.Minutes.ToString("00") + ":" + ts.Seconds.ToString("00");
                }
                else
                {
                    if (ts.Hours > 0)
                    {
                        xAxisLabels[cnt].Text = ts.Hours.ToString("00") + ":" + ts.Minutes.ToString("00") + ":" + ts.Seconds.ToString("00");
                    }
                    else
                    {
                        xAxisLabels[cnt].Text = ts.Minutes.ToString("00") + ":" + ts.Seconds.ToString("00");
                    }
                }
            }
        }
        private void Chart1_Customize(Object sender, EventArgs args)
        {
            // Get X and Y axis labels collections
            CustomLabelsCollection xAxisLabels = Chart1.ChartAreas["ChartArea1"].AxisX.CustomLabels;
            CustomLabelsCollection yAxisLabels = Chart1.ChartAreas["ChartArea1"].AxisY.CustomLabels;

            // Change text of the first Y axis label
            yAxisLabels[0].Text = "Zero";

            // Change Y axis labels
            for (int labelIndex = 1; labelIndex < yAxisLabels.Count; labelIndex++)
            {
                yAxisLabels[labelIndex].Text = yAxisLabels[labelIndex].Text + "°. 00'";
            }


            // Remove each second X axis label
            for (int labelIndex = 0; labelIndex < xAxisLabels.Count; labelIndex++)
            {
                // Adjust position of the previous label
                if (labelIndex > 0)
                {
                    xAxisLabels[labelIndex - 1].ToPosition   += (xAxisLabels[labelIndex].ToPosition - xAxisLabels[labelIndex].FromPosition) / 2.0;
                    xAxisLabels[labelIndex - 1].FromPosition -= (xAxisLabels[labelIndex].ToPosition - xAxisLabels[labelIndex].FromPosition) / 2.0;
                }

                // Remove label
                xAxisLabels.RemoveAt(labelIndex);
            }
        }
Ejemplo n.º 3
0
 public static void ClearFast(this CustomLabelsCollection collection)
 {
     collection.SuspendUpdates();
     while (collection.Count > 0)
     {
         collection.RemoveAt(collection.Count - 1);
     }
     collection.ResumeUpdates();
 }
Ejemplo n.º 4
0
    private void Chart1_Customize(Object sender, EventArgs args)
    {
        // Get X and Y axis labels collections
        CustomLabelsCollection xAxisLabels = Chart1.ChartAreas["ChartArea1"].AxisX.CustomLabels;

        // Change Y axis labels
        for (int labelIndex = 0; labelIndex < xAxisLabels.Count; labelIndex++)
        {
            //xAxisLabels[labelIndex].Text = AnnomesAFechaDescCorta(xAxisLabels[labelIndex].Text);
        }
    }
Ejemplo n.º 5
0
        /// <summary>
        /// Customise the x axis to display the year.
        /// </summary>
        /// <param name="sender">sender graph</param>
        /// <param name="e">event arguments</param>
        private void Chart1Customise(object sender, EventArgs e)
        {
            CustomLabelsCollection xAxisLabels = ((Chart)sender).ChartAreas[0].AxisX.CustomLabels;

            for (int cnt = 0; cnt < xAxisLabels.Count; cnt++)
            {
                TimeSpan ts        = TimeSpan.FromSeconds(double.Parse(xAxisLabels[cnt].Text));
                DateTime graphTime = this.graphStartTime + ts;
                xAxisLabels[cnt].Text = graphTime.Year.ToString("0000");
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="units"></param>
        /// <param name="volUnit"></param>
        /// <remarks>remember to filter out morphological totals</remarks>
        public void UpdateChart(System.IO.DirectoryInfo outputDir, IEnumerable <GCDCore.Project.Morphological.IBudgetGraphicalResults> units, UnitsNet.Units.VolumeUnit volUnit, bool bBudgetSeg, bool directional)
        {
            cmsChart = new UtilityForms.ChartContextMenu(outputDir, "morphological");
            chtData.ContextMenuStrip = cmsChart.CMS;

            // Update the Y axis volume units
            chtData.ChartAreas.ToList <ChartArea>().ForEach(x => x.AxisY.Title = string.Format("Volume ({0})", Volume.GetAbbreviation(volUnit)));

            // Clear all series data points
            chtData.Series.ToList <Series>().ForEach(x => x.Points.Clear());

            // Hide the second chart area if this is a non-directional budget seg
            chtData.ChartAreas[1].Visible = !bBudgetSeg || (bBudgetSeg && directional);

            CustomLabelsCollection xAxisLabels = chtData.ChartAreas[0].AxisX.CustomLabels;
            double maxY      = 0;
            double cumVolume = 0;

            foreach (GCDCore.Project.Morphological.IBudgetGraphicalResults unit in units)
            {
                double labelStart = chtData.Series[EROSION_CHART_SERIES].Points.Count;
                double labelEnd   = labelStart + 3;
                xAxisLabels.Add(new CustomLabel(labelStart, labelEnd, unit.Name, 0, LabelMarkStyle.Box));

                chtData.Series[EROSION_CHART_SERIES].Points.AddY(unit.VolErosion.As(volUnit));
                chtData.Series[EROSION_CHART_SERIES].Points.AddY(0);
                chtData.Series[EROSION_CHART_SERIES].Points.AddY(0);

                chtData.Series[DEPOSIT_CHART_SERIES].Points.AddY(0);
                chtData.Series[DEPOSIT_CHART_SERIES].Points.AddY(unit.VolDeposition.As(volUnit));
                chtData.Series[DEPOSIT_CHART_SERIES].Points.AddY(0);

                chtData.Series[ERROR___CHART_SERIES].Points.AddY(new object[] { unit.VolErosion.As(volUnit), (unit.VolErosion - unit.VolErosionErr).As(volUnit), (unit.VolErosion + unit.VolErosionErr).As(volUnit) });
                chtData.Series[ERROR___CHART_SERIES].Points.AddY(new object[] { unit.VolDeposition.As(volUnit), (unit.VolDeposition - unit.VolDepositionErr).As(volUnit), (unit.VolDeposition + unit.VolDepositionErr).As(volUnit) });
                chtData.Series[ERROR___CHART_SERIES].Points.AddY(new object[] { 0, 0, 0 });

                maxY = Math.Max(maxY, (unit.VolErosion + unit.VolErosionErr).As(volUnit));
                maxY = Math.Max(maxY, (unit.VolDeposition + unit.VolDepositionErr).As(volUnit));

                cumVolume += unit.VolDeposition.As(volUnit) - unit.VolErosion.As(volUnit);

                if (!bBudgetSeg)
                {
                    chtData.Series[VOLOUT__CHART_SERIES].Points.AddXY(unit.Name, unit.SecondGraphValue.As(volUnit));
                }
                else
                {
                    cumVolume += unit.VolDeposition.As(volUnit) - unit.VolErosion.As(volUnit);
                    chtData.Series[VOLOUT__CHART_SERIES].Points.AddXY(unit.Name, cumVolume);
                }
            }

            chtData.ChartAreas[0].AxisY.Maximum = Math.Ceiling(maxY);
            chtData.ChartAreas[0].AxisY.RoundAxisValues();

            foreach (int i in new List <int> {
                0, 1
            })
            {
                chtData.ChartAreas[i].AxisX.TitleFont       = Properties.Settings.Default.ChartFont;
                chtData.ChartAreas[i].AxisX.LabelStyle.Font = Properties.Settings.Default.ChartFont;
                chtData.ChartAreas[i].AxisY.TitleFont       = Properties.Settings.Default.ChartFont;
                chtData.ChartAreas[i].AxisY.LabelStyle.Font = Properties.Settings.Default.ChartFont;
            }
            chtData.Legends[0].Font = Properties.Settings.Default.ChartFont;

            // The data displayed on the second chart depends if this is being used for Morphological or Bs
            chtData.Series[VOLOUT__CHART_SERIES].LegendText        = !bBudgetSeg ? "Volume Out" : "Cumulative Volume Change";
            chtData.Series[VOLOUT__CHART_SERIES].IsVisibleInLegend = !bBudgetSeg || directional;
        }