Skip to content

Commit 70e3383

Browse files
committed
improved a little bit TableView, it can initialize cell controls later on (check PanelTableViewLazy class), so it's affects performance for the big tables;
fixed some Highchart issues (as I believe);
1 parent a5f9309 commit 70e3383

File tree

6 files changed

+359
-84
lines changed

6 files changed

+359
-84
lines changed

Controls/Highcharts/Highchart.cs

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
namespace Highcharts
1+
using System.Linq;
2+
3+
namespace Highcharts
24
{
35
using System;
46
using System.Collections.Generic;
@@ -135,16 +137,18 @@ public void RecalcCategories()
135137
cachedCategoriesStep = cachedPlotWidth;
136138
else
137139
cachedCategoriesStep = (float)cachedPlotWidth / (cachedCategories.Length - 1);
138-
140+
139141
if (cachedCategoriesStep < categoriesMinStep)
140142
{
141143
cachedCategoriesStep = categoriesMinStep;
142144

143145
// Filter categories.
144146
cachedCategoriesFiltered = new List<string>();
145147
for (float i = 0; i < cachedCategories.Length; i += skipFactor)
146-
cachedCategoriesFiltered.Add(cachedCategories[(int)i]);
148+
cachedCategoriesFiltered.Add(cachedCategories[(int) i]);
147149
}
150+
else
151+
cachedCategoriesFiltered = cachedCategories.ToList();
148152
}
149153
}
150154
}
@@ -321,6 +325,7 @@ private void DrawSeries(Graphics g, Series s)
321325
{
322326
double currentValue = s.data[(int) i];
323327

328+
bool last = i + pointInterval >= sdataCount;
324329
float currentValueYCoef = (float) ((currentValue - cachedPlotMin) / valueRange);
325330
float currentValueX = cachedPlotLeft + xStep * categoriesIndex;
326331
float currentValueY = cachedPlotTop + cachedPlotHeight - cachedPlotHeight * currentValueYCoef;
@@ -333,7 +338,7 @@ private void DrawSeries(Graphics g, Series s)
333338
{
334339
if (locationX + currentValueX < -uwfOffset.X) // Left side.
335340
clipHorizontal = true;
336-
if (locationX + currentValueX + xStep + uwfOffset.X > parentWidth) // Right side.
341+
if (locationX + currentValueX + uwfOffset.X > parentWidth) // Right side.
337342
clipHorizontal = true;
338343
}
339344

@@ -344,8 +349,6 @@ private void DrawSeries(Graphics g, Series s)
344349
{
345350
if (i > 0)
346351
{
347-
bool last = i + pointInterval >= sdataCount;
348-
349352
float prevValueYCoef = (float) ((prevValue - cachedPlotMin) / valueRange);
350353
float prevValueX = cachedPlotLeft + (categoriesIndex - 1) * xStep;
351354
float prevValueY = cachedPlotTop + cachedPlotHeight - cachedPlotHeight * prevValueYCoef;
@@ -366,8 +369,6 @@ private void DrawSeries(Graphics g, Series s)
366369
float prevValueX = cachedPlotLeft + (categoriesIndex - 1) * xStep;
367370
float prevValueY = cachedPlotTop + cachedPlotHeight - cachedPlotHeight * prevValueYCoef;
368371

369-
bool last = i + pointInterval >= sdataCount;
370-
371372
if (s.linearGradient == false)
372373
{
373374
g.uwfFillRectangle(areaColor, prevValueX, prevValueY, currentValueX - prevValueX,
@@ -408,10 +409,13 @@ private void DrawSeries(Graphics g, Series s)
408409
break;
409410
case SeriesTypes.line:
410411
{
411-
float prevValueYCoef = (float) ((prevValue - cachedPlotMin) / valueRange);
412-
float prevValueX = cachedPlotLeft + (categoriesIndex - 1) * xStep;
413-
float prevValueY = cachedPlotTop + cachedPlotHeight - cachedPlotHeight * prevValueYCoef;
414-
g.DrawLine(s.pen, prevValueX, prevValueY, currentValueX + 1, currentValueY);
412+
if (i > 0)
413+
{
414+
float prevValueYCoef = (float) ((prevValue - cachedPlotMin) / valueRange);
415+
float prevValueX = cachedPlotLeft + (categoriesIndex - 1) * xStep;
416+
float prevValueY = cachedPlotTop + cachedPlotHeight - cachedPlotHeight * prevValueYCoef;
417+
g.DrawLine(s.pen, prevValueX, prevValueY, currentValueX + 1, currentValueY);
418+
}
415419
}
416420
break;
417421
case SeriesTypes.lineSolid:
@@ -723,17 +727,12 @@ private double ValueAtX(Series s, int x)
723727
var sdataCount = s.data.Count;
724728
if (sdataCount == 0) return 0;
725729

726-
float pointInterval = s.pointInterval;
727-
float xStep = cachedCategoriesStep;
728-
if (sdataCount > 1)
729-
xStep = (float)cachedPlotWidth / (sdataCount - 1);
730-
xStep *= pointInterval;
731-
732-
var categoriesIndex = (int)((x - cachedPlotLeft) / xStep);
733-
if (categoriesIndex < 0 || categoriesIndex >= sdataCount)
730+
var xCoef = (float)(x - cachedPlotLeft) / cachedPlotWidth;
731+
var dataIndex = (int)(xCoef * sdataCount);
732+
if (dataIndex > sdataCount)
734733
return 0;
735734

736-
return s.data[categoriesIndex];
735+
return s.data[dataIndex];
737736
}
738737
}
739738
}

Controls/Highcharts/HightchartSubtitle.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
using System.Drawing;
44
using System.Windows.Forms;
55

6-
using DiaSimu;
7-
86
public class HightchartSubtitle
97
{
108
public HightchartSubtitle()

Controls/Highcharts/SeriesCollection.cs

Lines changed: 54 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
using System.Collections;
55
using System.Collections.Generic;
66

7-
public class SeriesCollection : IEnumerable, IDisposable
7+
public class SeriesCollection : IList<Series>, IDisposable
88
{
99
private readonly List<Series> items = new List<Series>();
1010
private readonly Highchart owner;
@@ -15,8 +15,13 @@ public SeriesCollection(Highchart o)
1515
}
1616

1717
public int Count { get { return items.Count; } }
18+
public bool IsReadOnly { get; private set; }
1819

19-
public Series this[int index] { get { return items[index]; } }
20+
public Series this[int index]
21+
{
22+
get { return items[index]; }
23+
set { throw new NotImplementedException(); }
24+
}
2025
public Series this[string name] { get { return items.Find(x => x.name == name); } }
2126

2227
public Series Add(string name)
@@ -53,11 +58,58 @@ public void Clear()
5358
owner.ResetColorIndex();
5459
owner.UpdateLegend();
5560
}
61+
public bool Contains(Series item)
62+
{
63+
return items.Contains(item);
64+
}
65+
public void CopyTo(Series[] array, int arrayIndex)
66+
{
67+
items.CopyTo(array, arrayIndex);
68+
}
69+
public Series Find(Predicate<Series> predicate)
70+
{
71+
return items.Find(predicate);
72+
}
73+
IEnumerator<Series> IEnumerable<Series>.GetEnumerator()
74+
{
75+
return items.GetEnumerator();
76+
}
5677
public IEnumerator GetEnumerator()
5778
{
5879
return items.GetEnumerator();
5980
}
81+
public int IndexOf(Series item)
82+
{
83+
return items.IndexOf(item);
84+
}
85+
public void Insert(int index, Series item)
86+
{
87+
if (item == null)
88+
throw new ArgumentNullException("item");
89+
90+
items.Insert(index, item);
91+
92+
item.NameChanged += Series_OnNameChanged;
93+
item.NameChanged -= Series_OnNameChanged;
94+
95+
owner.UpdateLegend();
96+
}
97+
public bool Remove(Series item)
98+
{
99+
if (item == null)
100+
throw new ArgumentNullException("item");
60101

102+
var removeResult = items.Remove(item);
103+
item.NameChanged -= Series_OnNameChanged;
104+
owner.UpdateLegend();
105+
106+
return removeResult;
107+
}
108+
public void RemoveAt(int index)
109+
{
110+
Remove(items[index]);
111+
}
112+
61113
public void Dispose()
62114
{
63115
UnsubscribeSeries();

0 commit comments

Comments
 (0)