' Gambas class file PRIVATE $iType AS Integer PUBLIC SUB _New(Value AS Integer) $iType = Value END PUBLIC SUB Draw(CX AS Integer, CY AS Integer, CW AS Integer, CH AS Integer) DIM oSerie AS _CSerie DIM cnt AS Integer DIM fMaxVal AS Float 'DIM itmp AS Float DIM i, j AS Integer DIM f AS Float DIM YHeadersW AS Integer DIM iTwoLetterHeight AS Integer = draw.Font.Height() * 2 * Chart._fProportionnal DIM iTabPos AS Integer 'DIM iXUnit AS Integer 'DIM iYUnit AS Integer 'DIM iGraphTop AS Integer 'DIM iGraphBottom AS Integer 'DIM iGraphLeft AS Integer DIM iGraphRight AS Integer DIM iStaticSpace AS Integer = 5 * Chart._fProportionnal DIM ariPoligone AS NEW Integer[] DIM aroPolygones AS NEW Object[] DIM hRect AS CRect DIM hUnits AS CPoint draw.Font.Size = 11 * Chart._fProportionnal SELECT CASE $iType CASE ChartType.Areas, ChartType.AreasSymbols fMaxVal = MTools.GetChartMaxValue(Chart) CASE ChartType.AreasStacked fMaxVal = MTools.GetChartMaxCumulateValue(Chart) CASE ChartType.AreasPercent fMaxVal = 100 END SELECT IF fMaxVal = 0 THEN RETURN cnt = draw.TextWidth(fMaxVal & "00") 'Get the max width needed for draw the Y labels YHeadersW = CX + iStaticSpace + cnt + iStaticSpace * 2 hRect = NEW CRect 'Set the graph square position value hRect.Top = CY + iTwoLetterHeight hRect.Bottom = CY + CH - iTwoLetterHeight hRect.Left = YHeadersW hRect.Right = CX + CW - YHeadersW 'Draw the background Draw.ForeColor = Color.LightGray Draw.FillColor = Color.LightGray Draw.FillStyle = Fill.Solid Draw.Rect(hRect.Left, hRect.Top, hRect.Right - hRect.Left, hRect.Bottom - hRect.Top) Draw.ForeColor = Color.Black hUnits = MTools.DrawChartAxes(Chart, hRect, 0, fMaxVal) IF Chart.Count < 2 THEN RETURN Draw.FillStyle = Fill.Solid FOR j = 0 TO Chart.CountDataSets - 1 ariPoligone = NEW Integer[] ariPoligone.Resize(Chart.Count * 2) aroPolygones.Add(ariPoligone) NEXT FOR i = 0 TO Chart.Count - 1 f = 0 fMaxVal = 0 FOR j = 0 TO Chart.CountDataSets - 1 fMaxVal += Chart[j][i] NEXT FOR j = 0 TO Chart.CountDataSets - 1 SELECT CASE $iType CASE ChartType.AreasPercent f += Chart[j][i] / fMaxVal * 100 CASE ChartType.AreasStacked f += Chart[j][i] CASE ELSE f = Chart[j][i] END SELECT aroPolygones[j][i * 2] = hRect.Left + (hUnits.X * i) aroPolygones[j][i * 2 + 1] = hRect.Bottom - f * hUnits.Y NEXT NEXT FOR j = 0 TO Chart.CountDataSets - 1 aroPolygones[J].Add(aroPolygones[J][aroPolygones[J].max - 1]) aroPolygones[J].Add(hRect.Bottom) aroPolygones[J].Add(hRect.Left) aroPolygones[J].Add(hRect.Bottom) NEXT FOR i = aroPolygones.Max TO 0 STEP -1 Draw.FillColor = Chart.Colors[i] draw.Polygon(aroPolygones[i]) NEXT IF $iType = ChartType.AreasSymbols THEN FOR i = 0 TO aroPolyGones.Max FOR j = 0 TO aroPolyGones[i].Max - 4 STEP 2 Draw.LineWidth = 1 Draw.FillColor = Chart.Colors[i] Draw.ForeColor = Color.DarkGray MTools.DrawSymbol(i, aroPolyGones[i][j], aroPolyGones[i][j + 1]) NEXT NEXT ENDIF END .