LightningChart totally black

A forum dedicated to WinForms version of LightningChart Ultimate.

Moderator: Queue Moderators

Post Reply
Harry943
Posts: 8
Joined: Tue Dec 26, 2017 6:46 am

LightningChart totally black

Post by Harry943 » Tue Sep 29, 2020 9:52 am

Hello,
I have a winforms program using LightningChart, and I override CreateParams in Form class for some reason and put LightingChart in a custom panel, then the LightningChart will go totally black, is there some where I do is wrong? Attached file demo project simply override CreateParams, and will show the black screen when launch, then turn to right content, but in my program it's get totally black all the time.

black when launch
Image

normal after launch
Image

totally black in my program
Image
Attachments
WindowsFormsApp1.7z
(116.14 KiB) Downloaded 407 times
Last edited by Harry943 on Tue Sep 29, 2020 9:56 am, edited 1 time in total.

Harry943
Posts: 8
Joined: Tue Dec 26, 2017 6:46 am

Re: LightningChart totally black

Post by Harry943 » Tue Sep 29, 2020 9:55 am

Code for override CreateParams

Code: Select all

protected override CreateParams CreateParams
{
    get
    {
        CreateParams cp = base.CreateParams;
        cp.ExStyle |= 0x02000000;
        return cp;
    }
}

Arction_LasseP
Posts: 141
Joined: Wed Mar 27, 2019 1:05 pm

Re: LightningChart totally black

Post by Arction_LasseP » Wed Sep 30, 2020 1:49 pm

Hello Harry,

We tried to reproduce this issue with the test project you shared, but couldn't produce a situation where the chart remained completely black.

There are two forms in the project, ReadData and Form1. Both work with CreateParams added.

ReadData is first black, then the chart is shown.
ReadData.PNG
ReadData.PNG (21.89 KiB) Viewed 6070 times
Form1 is first Transparent, then the chart is shown.
Form1.PNG
Form1.PNG (17.01 KiB) Viewed 6070 times
Does the issue happen in that test project in your machine? If it does, does the chart render normally if you leave out the CreateParams? This would tell if the cause actually is CreateParams.
The only known case of a completely black chart is when there are some references missing. In the test project they seems to be correct, but just in case you could test to add also Arction.DirectXFiles.dll, DirectXInit.dll and Arction.MathCore.dll.

Best regards,
Lasse

hyetc
Posts: 11
Joined: Fri Oct 09, 2020 9:26 am

Re: LightningChart totally black

Post by hyetc » Fri Oct 09, 2020 9:30 am

I have the same problem, probably with RenderOptions.DeviceType = rendererdevicetype.auto;Is related to hardware acceleration caused this problem, instead RenderOptions. DeviceType = RendererDeviceType. SoftwareOnlyD11;Without this problem, the key changed to this form and the performance did not play out

Arction_LasseP
Posts: 141
Joined: Wed Mar 27, 2019 1:05 pm

Re: LightningChart totally black

Post by Arction_LasseP » Wed Oct 14, 2020 1:17 pm

Hello,

As mentioned, a totally black chart can occur if there are some references missing. Our User's Manual chapter 29.1 has a complete list of references. When developing, not necessarily all of these files are needed, for example if DirectX -files can already be found already somewhere in the machine. Referencing all the assemblies listed can solve the black chart issue.

However, if rendering DeviceType SoftwareD11 works but not HardwareD11 or Hardware D9, there probably is something wrong with the drivers themselves, as they could be buggy or outdated. Therefore, updating the drivers to the newest version can help.

In general, RenderingEngine errors can be caught via listening to ChartMessage -event right after LightningChart is constructed and calling CheckEngineResult() -method in it. For instance:

Code: Select all

private void _chart_ChartMessage(ChartMessageInfo info)
        {
            info.ToString(); //= log message
 
            if (info.MessageType == MessageType.RenderDeviceCreateFailed || info.MessageType == MessageType.MemoryAllocationError)
            {
                CheckEngineResult();
            }
       }
 
 
private void CheckEngineResult()
        {
            var results = _chart.GetLastEngineInitResults();
 
            foreach (var engineInitResult in results)
            {
                string sLog = string.Format("Engine {0}. Success:{1}", engineInitResult.DeviceType, engineInitResult.Success);
 
                foreach (var exception in engineInitResult.Exceptions)
                {
                    sLog = string.Format("{0}\n Exception: {1}", sLog, exception.Message);
                }
                System.Diagnostics.Debug.WriteLine(sLog);
            }
       }
Best regards,
Lasse

hyetc
Posts: 11
Joined: Fri Oct 09, 2020 9:26 am

Re: LightningChart totally black

Post by hyetc » Thu Nov 12, 2020 9:12 am

The problem is still unresolved, the engine has no problem, and the override parameter method will have a black background problem.And in Windows 7 system will be more obvious, I hope you can cause attention, this is really a very serious problem.If you think about it, it's going to be a big black patch when it loads, and it's going to be a really bad experience.The following code addresses the splash screen problem caused by too many widgets in our window layout.

protected override CreateParams CreateParams
{
get
{
CreateParams cp = base.CreateParams;
cp.ExStyle |= 0x02000000;
return cp;
}
}

Arction_LasseP
Posts: 141
Joined: Wed Mar 27, 2019 1:05 pm

Re: LightningChart totally black

Post by Arction_LasseP » Fri Nov 13, 2020 9:43 am

Hello,

We investigated this issue more, and possibly were able to reproduce it. Is the following what is happening in your application when using CreateParams?

When the app is started WinForms controls such as buttons are drawn but the chart remains black (left image below). After a short time, the chart is drawn (right image below).
BlackChart.png
BlackChart.png (399.01 KiB) Viewed 5572 times
What is the chart's behaviour you are trying to accomplish? Should the controls and the chart be drawn at the same time? If this is the case, you most likely have to delay the drawing of the controls somehow. This could be done by overriding OnPaint method or by using SuspendLayout and ResumeLayout. However, one workaround is to hide the controls until the chart has been drawn. In other words, set Visible property for all controls false by default, then in chart's Paint event, set it true. The example code below shows all buttons only after the chart has been drawn.

Code: Select all

_chart.Paint += _chart_Paint;

        private void _chart_Paint(object sender, PaintEventArgs e)
        {
            _chart.Paint -= _chart_Paint; // Do this only once.
            foreach (var b in this.Controls.OfType<Button>())
            {
                b.Visible = true;
            }
        }
Best regards,
Lasse

Post Reply