I have an ASP.net project and I'm using Javascript/HTML5 steema teechart in my project.
I want to update lines data every second, but the problem is the whole chart will update and cause flickering/blinking.
Can someone please help me with this problem?
This is my Controller code:
Code: Select all
public ActionResult TrendingChart()
{
lock (renderLock)
{
wChart3.Panel.Color = ColorTranslator.FromHtml("#FF000000");
wChart3.Header.Visible = false;
wChart3.Axes.Bottom.Ticks.Visible = true;
wChart3.Footer.Visible = true;
wChart3.Footer.Text = "bbl/hr";
wChart3.Footer.Font.Color = System.Drawing.Color.GhostWhite;
wChart3.Axes.Bottom.Increment = 10000;
wChart3.Axes.Bottom.SetMinMax(0, 100000);
wChart3.Axes.Bottom.Grid.Visible = true;
wChart3.Axes.Left.Ticks.Visible = true;
wChart3.Axes.Left.SetMinMax(0, 22);
wChart3.Axes.Left.Increment = 2;
wChart3.Legend.Visible = false;
for (int i = 0; i < 32; i++)
{
_line[i] = new Steema.TeeChart.Styles.Line();
_line[i].LinePen.Width = 3;
wChart3.Series.Add(_line[i]);
}
double[] TagValues = new double[108];
TagValues = _client.ScanOpcServerData();
DrawP1(TagValues[50], true);
DrawP2(TagValues[50], false);
DrawP3(TagValues[50], false);
DrawPointOfOperation(TagValues[48], TagValues[49]);
DrawStaticMpsIpsGraph();
DrawLimitGraphs();
wChart3.Series[0].Add(_line[0]);
wChart3.Series[1].Add(_line[1]);
wChart3.Series[2].Add(_line[2]);
wChart3.Series[3].Add(_line[3]);
wChart3.Series[4].Add(_line[4]);
wChart3.Series[5].Add(_line[5]);
wChart3.Series[6].Add(_line[6]);
wChart3.Series[7].Add(_line[7]);
wChart3.Series[8].Add(_line[8]);
wChart3.Series[9].Add(_line[9]);
wChart3.Series[10].Add(_line[10]);
wChart3.Series[11].Add(_line[11]);
wChart3.Series[12].Add(_line[12]);
wChart3.Series[13].Add(_line[13]);
MemoryStream tempStream = new MemoryStream();
wChart3.Export.Image.JScript.SourceScriptPath = "/Scripts";
wChart3.Export.Image.JScript.Width = 1180;
wChart3.Export.Image.JScript.Height = 730;
wChart3.Export.Image.JScript.Save(tempStream);
tempStream.Position = 0;
StreamReader sr = new StreamReader(tempStream);
return Content(sr.ReadToEnd());
}
}
And this is my .cshtl code
Code: Select all
<!DOCTYPE html>
<html style="width:1433px;height:952px">
<head>
<script src="~/Scripts/jquery-3.4.1.min.js"></script>
<script type="text/javascript">
// Read data on interval
setInterval(function () {
ReadData();
}, 1000);
function ReadData() {
document.getElementById('frTrendingChart').src = "/Home/TrendingChart"; // Repaint TeeChart
}
</script>
</head>
<body>
<div>
<iframe id="frTrendingChart" hidden="hidden" style="border:none; width:1200px; height:750px;background-color:black" />
</div>
</body>
</html>