Wierd drawing issue

A forum dedicated to WPF version of LightningChart Ultimate.

Moderator: Queue Moderators

Post Reply
fischertc
Posts: 18
Joined: Wed Feb 12, 2014 6:16 am

Wierd drawing issue

Post by fischertc » Wed Apr 16, 2014 8:44 am

Hello,

I am using version 5.4.1.4001

I have a chart with barseries assigned whose width I control. Most of the barseries objects have a solid fill color. When the data is reaches a specific value, I have to change the fill to a tiled bitmap.

Whats happening is that sometimes the chart is drawing this bitmap outside of the plot borders. I have attached a couple of png files that show what I see on the screen. You can clearly see the border of the plotting area to the right side of the each and on the left it is drawing this bitmap.

The barseries fill is being set like this:

void SetSeriesFillColor(ConfidenceTypes confidence, BarSeries series, ...)
{
...
if (confidence == Low)
{
// Set a default color
series.Fill.Color = loColor;
series.Fill.GradientFill = GradientFill.Solid;

// If the low conf bitmap was created
if (_lowFillImage != null)
{
// Set the fill to use it tiled
series.Fill.Bitmap.Image = _lowFillImage;
series.Fill.Style = RectFillStyle.Bitmap;
series.Fill.Bitmap.Layout = BitmapFillLayout.Tile;
}
...
}

The bitmap just shows up randomly when the user is scrolling back and forth and a barseries with this bitmap in it is scrolled close to the edge or sometimes, as in the png's it scrolls off the screen. On the second png a band has just scrolled offscreen and the fill is being drawn on the YAxis border.
Attachments
bitmap_on_outside2.png
bitmap_on_outside2.png (18.03 KiB) Viewed 15622 times
bitmap_on_outside.png
bitmap_on_outside.png (51.83 KiB) Viewed 15622 times

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

Re: Wierd drawing issue

Post by ArctionPasi » Wed Apr 16, 2014 10:50 am

Thanks. Problem confirmed in tiled Bitmap fill. Resolving...
LightningChart Support Team, PT

Administrator
Site Admin
Posts: 4
Joined: Sun Mar 24, 2013 11:14 am

Re: Wierd drawing issue

Post by Administrator » Wed Apr 16, 2014 12:35 pm

That has been fixed now, download new assemblies from http://www.arction.com/download/LC_v.5. ... x_net4.zip.

Our apologies for the trouble :oops:

fischertc
Posts: 18
Joined: Wed Feb 12, 2014 6:16 am

Re: Wierd drawing issue

Post by fischertc » Thu Apr 17, 2014 2:28 am

That didn't fix it.

I renamed the current toolbox\assemblies\wpf directory files and copied the new WPF ones to it. I then rebuilt a debug version and verified the new WPF dll's are in the bin\debug directory. I then tested it and it is still broken.

I then copied the dlls and overwrote those in a current x86 programs files installation and it is also not working.

ArctionTero
Posts: 42
Joined: Thu Mar 28, 2013 9:20 am

Re: Wierd drawing issue

Post by ArctionTero » Thu Apr 17, 2014 9:48 am

Sorry to hear the fix didn't work. We found something alike with our demo and got it fixed.

For replication, it would be help, if you could provide a bit more information:
- Details, how you initialize BarSeries and BarViewOptions?
- You mentioned Band in the initial post. Was it typo or have you added Bands in the chart?
- Any other objects in the chart?

Thank you.
LightningChart Support Team, TK

fischertc
Posts: 18
Joined: Wed Feb 12, 2014 6:16 am

Re: Wierd drawing issue

Post by fischertc » Wed Apr 23, 2014 1:59 am

I updated the scrollbar sample to add bars and a tiled bitmap. I copied the updated dlls you passed on to me into the toolset install of WPF, the GAC install and added the WPF dlls to the bin\debug directory on the sample application just to be sure. I still see bitmaps tiled on the the bars being drawn outside the plotting area in the sample application.

To answer your questions:

- Details, how you initialize BarSeries and BarViewOptions?

A: The app creates an IEnumerable set of data values used as input to this bar chart. There is also a set of marked locations where bands are added to show properties of a specific location on the chart.

Code: Select all

foreach (BarData value in values)
{
     BarSeries series = new BarSeries(_chart.ViewXY, _chart.ViewXY.XAxes[0], _chart.ViewXY.YAxes[0]);

     series.AddValue(value.Value.Location, value.Value.Value, value.Value.Text, false);
     series.IncludeInAutoFit = true;
     series.LabelStyle.Visible = false;
     series.Title.ShowInLegendBox = false;

     // This sets the color or bitmap
     SetSeriesFillColor(value.Confidence, series, value.IsOverlay ? DepthBarColorElement.BarTypes.Overlay : DepthBarColorElement.BarTypes.Standard);
   _chart.ViewXY.BarSeries.Add(series);
   _chart.ViewXY.BarViewOptions.Grouping = BarsGrouping.ByLocation;
}

SetSeriesFillColor(value.Confidence, series, value.IsOverlay ? DepthBarColorElement.BarTypes.Overlay : DepthBarColorElement.BarTypes.Standard);
{
...
       if (confidence == ConfidenceTypes.Low)
       {
            series.Fill.Color = loFillColor;
            series.Fill.GradientFill = GradientFill.Solid;

            if (_lowFillImage != null)
           {
                series.Fill.Bitmap.Image = _lowFillImage;
                series.Fill.Style = RectFillStyle.Bitmap;
                series.Fill.Bitmap.Layout = BitmapFillLayout.Tile;
           }
      }
      else
      {
           series.Fill.Color = (confidence == ConfidenceTypes.High ? hiFillColor : medFillColor);
           series.Fill.GradientFill = GradientFill.Solid;
      }
}

Bar widths are modified whenever the X Axis range changed handler is called.

- You mentioned Band in the initial post. Was it typo or have you added Bands in the chart?

A: Yes there is a moveable band on the chart and there are also 0..N colored bands that are assigned to specific locations as markers. The drawing issue will occur with/without marker bands.

- Any other objects in the chart?

Apart from the scrolling band and the marker bands no, nothing else.

Here is the updated ExampleScrollBar.cs where I still see the problem:

Code: Select all

using System;
using System.Windows.Forms;

using Arction.LightningChartUltimate;
using Arction.LightningChartUltimate.SeriesXY;

namespace DemoAppLightningChartUltimate
{
	public partial class ExampleScrollBar : UserControl
	{
		private const Int32 SampleCount = 1000;

		private LightningChartUltimate m_chart;
		
		public ExampleScrollBar()
		{
			m_chart = null;
			
			InitializeComponent();
			CreateChart();
		}

		/// <summary> 
		/// Clean up any resources being used.
		/// </summary>
		/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
		protected override void Dispose(bool disposing)
		{
			if (disposing && (components != null))
			{
				if (m_chart != null)
				{
					m_chart.Dispose();
					m_chart = null;
				}
				
				components.Dispose();
			}
			
			base.Dispose(disposing);
		}
		
		/// <summary>
		/// Get demo description and source file name.
		/// </summary>
		/// <param name="sourceCodeFilename">Demo source file name</param>
		/// <returns>description</returns>
		public string GetDescription(out string sourceCodeFilename)
		{
			//Resolve source code file name by throwing an exception and investigating the source file name 
			try
			{
				throw new Exception();
			}
			catch (Exception e)
			{
				sourceCodeFilename = ChartTools.GetSourceCodeFilenameFromStackTrace(e.StackTrace);
			}
			return "Simple scroll bar example with 10000 data points.";
		}

		private void CreateChart()
		{
			// Create a new chart.
			m_chart = new LightningChartUltimate(LicenseKeys.LicenseKeyStrings.LightningChartUltimate);

			m_chart.BeginUpdate();
			
			m_chart.Name = "Simple scroll bar chart";
			// Chart parent must be set.
			m_chart.Parent = this;
			// Fill parent area with chart.
			m_chart.Dock = DockStyle.Fill;

			Random rand = new Random((Int32)DateTime.Now.Ticks);
			SeriesPoint[] aValues = new SeriesPoint[SampleCount];
			for (int i = 0; i < SampleCount; i++)
			{
				aValues[i].X = i;
				aValues[i].Y = (rand.NextDouble() * 2000.0) - 1000.0;
			}

			m_chart.ViewXY.DropOldSeriesData = false;
			m_chart.ViewXY.GraphBackground.GradientFill = GradientFill.Radial;
			m_chart.ViewXY.XAxes[0].Maximum = SampleCount / 10;
			m_chart.ViewXY.XAxes[0].Title.Visible = false;
			m_chart.ViewXY.XAxes[0].ValueType = AxisValueType.Number;
			m_chart.ViewXY.XAxes[0].RangeChanged += new Arction.LightningChartUltimate.Axes.AxisBase.RangeChangedHandler(ExampleScrollBar_RangeChanged);
			m_chart.ViewXY.YAxes[0].Maximum = 1000.0;
			m_chart.ViewXY.YAxes[0].Minimum = -1000.0;
			m_chart.ViewXY.YAxes[0].Title.Visible = false;

			PointLineSeries series = new PointLineSeries(m_chart.ViewXY, m_chart.ViewXY.XAxes[0], m_chart.ViewXY.YAxes[0]);
			series.AddPoints(aValues, false);

            for (int i = 0; i < SampleCount; i++)
            {
                BarSeriesValue[] aData = new BarSeriesValue[1];
                aData[0].Value = (rand.NextDouble() * 2000.0) - 1000.0;
                aData[0].Location = i;
                //Set label text
                aData[0].Text = aData[0].Value.ToString("0");

                BarSeries bs = new BarSeries(m_chart.ViewXY, m_chart.ViewXY.XAxes[0], m_chart.ViewXY.YAxes[0]);

                //Set series title 
                bs.Title.Text = "Data " + (i + 1).ToString();
                //Set series fill 
                bs.Fill.Color = DefaultColors.Series[i % 16];
                bs.Fill.GradientColor = ChartTools.CalcGradient(DefaultColors.Series[i % 16], System.Drawing.Color.Black, 50);

                if ((i % 20) == 0)
                {
                    bs.Fill.Style = RectFillStyle.Bitmap;
                    bs.Fill.Bitmap.Layout = BitmapFillLayout.Tile;
                    bs.Fill.Bitmap.Image = Properties.Resources.WelcomePic500; 
                }

                //Set label text style
                bs.LabelStyle.Angle = 0;
                bs.LabelStyle.VerticalAlign = BarsTitleVerticalAlign.BarTop;

                //Assign the value
                bs.Values = aData;

                m_chart.ViewXY.BarSeries.Add(bs);
            }

            m_chart.ViewXY.BarViewOptions.Grouping = BarsGrouping.ByLocation;
            m_chart.ViewXY.BarViewOptions.BarSpacing = 1;
            m_chart.ViewXY.BarViewOptions.Orientation = BarsOrientation.Vertical;  

			m_chart.ViewXY.PointLineSeries.Clear();
			m_chart.ViewXY.PointLineSeries.Add(series);

			Arction.LightningChartUltimate.ScrollBar sb = new Arction.LightningChartUltimate.ScrollBar(m_chart);
			sb.Minimum = 0;
			sb.Maximum = (UInt64)SampleCount - 1;
			sb.Scroll += new Arction.LightningChartUltimate.ScrollBar.ScrollHandler(sb_Scroll);
			sb.LargeChange = (UInt64)m_chart.ViewXY.XAxes[0].Maximum;
			sb.Offset = new PointIntXY(sb, 0, 35);

			m_chart.ScrollBars.Add(sb);

			m_chart.EndUpdate();
		}

		private void ExampleScrollBar_RangeChanged(double newMin, double newMax, Arction.LightningChartUltimate.Axes.AxisBase axis, ref bool cancelRendering)
		{
			m_chart.ScrollBars[0].LargeChange = (UInt64)(newMax - newMin);
			m_chart.ScrollBars[0].Value = (UInt64)newMin;
		}

		private void sb_Scroll(object sender, ScrollBarScrollType type, ulong oldValue, ulong newValue)
		{
			Double dMaximum = newValue + m_chart.ScrollBars[0].LargeChange;
			if (dMaximum > SampleCount)
			{
				return;
			}

			m_chart.BeginUpdate();
			m_chart.ViewXY.XAxes[0].SetRange(newValue, newValue + m_chart.ScrollBars[0].LargeChange);
			m_chart.EndUpdate();
		}
	}
}



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

Re: Wierd drawing issue

Post by ArctionPasi » Wed May 07, 2014 1:55 pm

Please update to 6.0 and let us know if the problem still persists.
LightningChart Support Team, PT

Post Reply