LC is looping after fonts updating

A forum dedicated to WinForms version of LightningChart Ultimate.

Moderator: Queue Moderators

Post Reply
MaksimNikitin
Posts: 6
Joined: Mon Sep 28, 2015 12:01 pm

LC is looping after fonts updating

Post by MaksimNikitin » Mon Sep 28, 2015 12:19 pm

Hey all, I have quite strange problem after updating from 5.5.1 to 6.4.2.

I have simple for-cycle where I create y-axis for graphs collections:

Code: Select all

for (int iSegment = 0; iSegment < CurrentChList.Count; iSegment++)
         {
                var ch = CurrentChList[iSegment];
                if (!ch.isLoaded)
                {
                    AxisY axisY = CreateAxisY(m_THPlot.ViewXY, ch);    //this method is called, we send ViewXY plotter propperty
                    m_THPlot.ViewXY.YAxes.Insert(iSegment, axisY);
                    ///////////////////.......................................
               }
          }
In CreateAxisY method I create new axis and return it:

Code: Select all

 virtual protected AxisY CreateAxisY(ViewXY viewXY, ChanelEntry ch = null)
        {
            double min = ch == null ? -10 : ch.minY;
            double max = ch == null ? 10 : ch.maxY;
            string text = ch == null ? String.Empty : ch.Unit;
            Color color = ch == null ? Color.Black : ch.colorChanel;

            AxisY axisY = new AxisY(viewXY);
            axisY.Minimum = min;
            axisY.Maximum = max;
            axisY.MiniScale.Visible = false;
            axisY.AutoDivSeparationPercent = 10;
            axisY.LabelsNumberFormat = "";
            axisY.AxisThickness = 1;
            axisY.LabelTicksGap = 0;
            axisY.MajorGrid.Color = Color.Silver;
            axisY.MajorGrid.Visible = true;
            axisY.MinorDivCount = 1;
            axisY.LabelsFont = new Font(FontChartArea, FontChartArea.Style);          // problem place

            axisY.Title.Visible = true;
            axisY.Title.Text = text;
            axisY.Title.Font = new Font(FontChartArea, FontChartArea.Style);
            axisY.Title.Color = color;
            axisY.Title.VerticalAlign = YAxisTitleAlignmentVertical.Center;
            axisY.Title.HorizontalAlign = YAxisTitleAlignmentHorizontal.Left;
            axisY.Title.Shadow.Style = TextShadowStyle.Off;
            axisY.Title.MoveByMouse = false;
            axisY.Title.MouseInteraction = false;
            axisY.Title.DistanceToAxis = mkDistanceToAxis;
            axisY.AxisColor = Color.Black;

            axisY.Units.Visible = false;
            axisY.Units.Text = "";
            axisY.LabelsColor = Color.Black;
            axisY.Alignment = AlignmentHorizontal.Left;
            axisY.MouseScrolling = false;
            axisY.MouseScaling = false;

            axisY.LabelsNumberFormat = mkSetValuesScientificFormatString;

            //axisY.FormatValueLabel += new AxisBase.FormatValueLabelHandler(axisY_FormatValueLabel);

            return axisY;
        }
Sometimes I have looping (cycling) in this place:

Code: Select all

axisY.LabelsFont = new Font(FontChartArea, FontChartArea.Style);
This problem is actual after updating from 5.5.1 to 6.4.2

Any ideas? This is very critical problem for me now. Any help would be appropriate!

User avatar
ArctionPasi
Posts: 1367
Joined: Tue Mar 26, 2013 10:57 pm
Location: Finland
Contact:

Re: LC is looping after fonts updating

Post by ArctionPasi » Mon Sep 28, 2015 1:48 pm

Hello.

Maybe FontChartArea is disposed somewhere. Please troubleshoot by creating a member variable
private Font _font = new Font("Arial", 13f);

and using that font as prototype for other objects.

Note that if chart is given a font directly, like chart.ViewXY.XAxes[0].Title.Font = _font, and the chart is disposed, it disposes the font too. Chart assumes ownership of the given font.
LightningChart Support Team, PT

MaksimNikitin
Posts: 6
Joined: Mon Sep 28, 2015 12:01 pm

Re: LC is looping after fonts updating

Post by MaksimNikitin » Mon Sep 28, 2015 2:20 pm

FontChartArea is a member of my class and I use it every time when I set a font as a prototype:

Code: Select all

private readonly Font FontChartArea= new Font("Microsoft Sans Serif", 10);
And it is not disposed right before setting LabelsFont property of axis.

UPD:

Code: Select all

axisY.LabelsFont = new Font("Microsoft Sans Serif", 10);
If I use this way, result is the same.

User avatar
ArctionPasi
Posts: 1367
Joined: Tue Mar 26, 2013 10:57 pm
Location: Finland
Contact:

Re: LC is looping after fonts updating

Post by ArctionPasi » Mon Sep 28, 2015 2:29 pm

Clease you please post a simple VS project to reproduce the issue?
LightningChart Support Team, PT

MaksimNikitin
Posts: 6
Joined: Mon Sep 28, 2015 12:01 pm

Re: LC is looping after fonts updating

Post by MaksimNikitin » Tue Sep 29, 2015 8:16 am

I think that to reproduce the bug it's enough just set to axisY.Minimum and to axisY.Maximum the same values. I did not pay attention to this fact yesterday.
If I add to CreateAxisY method this spike:

Code: Select all

 if (min == max)
            {
                max += 1;
            }
Everything works properly. I think this is quite critical issue in LC control and you, guys, should fix it asap :)

User avatar
ArctionPasi
Posts: 1367
Joined: Tue Mar 26, 2013 10:57 pm
Location: Finland
Contact:

Re: LC is looping after fonts updating

Post by ArctionPasi » Wed Sep 30, 2015 9:26 am

I'm sorry but I don't understand the problem you are encountering, or what should we fix here.

By setting same value for axis minimum and maximum will automatically adjust minimum slightly lower, because it is impossible to render the chart with same Y axis value in the top and in the bottom.

By using range 50...50, it will show up at range 4.999999999950 E+1 ... 5.0000000000 E+1. That is the designed behavior when setting invalid range.

Can you please modify the code below, until I can see the looping problem.

Code: Select all


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Arction.LightningChartUltimate; 


namespace AxisTest
{
    public partial class Form1 : Form
    {

        LightningChartUltimate _chart; 
        
        public Form1()
        {
            InitializeComponent();

            _chart = new LightningChartUltimate();

            _chart.Parent = this;
            
            _chart.BeginUpdate(); 
            _chart.Dock = DockStyle.Fill;

            //_chart.ViewXY.YAxes[0].SetRange(50, 50); //Invalid range 
            _chart.ViewXY.YAxes[0].SetRange(0, 50); //Valid range 



            _chart.EndUpdate(); 
        }
    }
}
LightningChart Support Team, PT

Post Reply