Steema Issues Database

Note: This database is for bugs and wishes only. For technical support help, if you are a customer please visit our online forums;
otherwise you can use StackOverflow.
Before using this bug-tracker we recommend a look at this document, Steema Bug Fixing Policy.



Bug 1896 - Advisory. When using TeeChart in an MVC ActionResult duplicate hash id error occurs during multi-access
Summary: Advisory. When using TeeChart in an MVC ActionResult duplicate hash id error ...
Status: RESOLVED FIXED
Alias: None
Product: .NET TeeChart
Classification: Unclassified
Component: Exporting (show other bugs)
Version: unspecified
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Steema Issue Manager
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-07-21 04:13 EDT by marc meumann
Modified: 2017-07-21 04:14 EDT (History)
0 users

See Also:
Chart Series: ---
Delphi / C++ Builder RAD IDE Version:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description marc meumann 2017-07-21 04:13:58 EDT
TeeChart being rendered in export in MVC application in image format (eg PNG, JPEG). During simultaneous access duplicate hash id key error is generated.

This occurs in the Canvas paint code and relates to generic limitations of multiple access in GDI+.


The problem  has workarounds. You can turn off use of the cache for improvements.
ie.
Steema.TeeChart.Utils.UseCaches = false;

But the recommended way to use TeeChart as an MVC component, for multiple simultaneous access, is to add a lock around the Chart rendering code.

eg.
==========
private static Object renderLock = new Object();

public void GetChart()
{
  lock (renderLock)
  {
    Steema.TeeChart.Web.WebChart wChart = new Steema.TeeChart.Web.WebChart();

    //Steema.TeeChart.Utils.UseCaches = false;

    wChart.Chart.Series.Add(new Steema.TeeChart.Styles.Line());
    wChart.Chart.Series[0].FillSampleValues();

    tempStream1 = new System.IO.MemoryStream();
    wChart.Chart.Export.Image.PNG.Save(tempStream1);
    tempStream1.Flush();
    Response.ContentType = "Image/PNG";
    Response.OutputStream.Write(tempStream1.ToArray(), 0, (int)tempStream1.Length);

    tempStream1.Close();
  }
}
=======
or
=======
public ActionResult GetHTML5Chart(int? number) {

lock (renderLock)
{
  Steema.TeeChart.Web.WebChart wChart3 = new Steema.TeeChart.Web.WebChart();

  if (number==0)
    wChart3.Chart.Series.Add(new Steema.TeeChart.Styles.Pie());
  else if (number==1)
    wChart3.Chart.Series.Add(new Steema.TeeChart.Styles.Bar());
  else
    wChart3.Chart.Series.Add(new Steema.TeeChart.Styles.Line());
  wChart3.Chart.Series[0].FillSampleValues();

  string[] customCode = new string[] {

          " chart1.applyTheme(\"minimal\");" };

  wChart3.Chart.Export.Image.JScript.CustomCode = customCode;

  tempStream2 = new System.IO.MemoryStream();
  wChart3.Chart.Export.Image.JScript.Width = 900;
  wChart3.Chart.Export.Image.JScript.Height = 300;
  wChart3.Chart.Export.Image.JScript.Save(tempStream2);

  tempStream2.Position = 0;

  System.IO.StreamReader sr = new System.IO.StreamReader(tempStream2);

  return Content(sr.ReadToEnd());
}
==========