' 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 ariPolyLine AS NEW Integer[] DIM aroPolyLines AS NEW Object[] DIM iStaticSpace AS Integer = 5 * Chart._fProportionnal DIM hRect AS NEW CRect DIM hUnits AS CPoint draw.Font.Size = 11 * Chart._fProportionnal SELECT CASE $iType CASE ChartType.Lines, ChartType.LinesSymbols fMaxVal = MTools.GetChartMaxValue(Chart) CASE ChartType.LinesStacked fMaxVal = MTools.GetChartMaxCumulateValue(Chart) CASE ChartType.LinesPercent fMaxVal = 100 END SELECT cnt = draw.TextWidth(fMaxVal & "00") 'Get the max width needed for draw the Y labels YHeadersW = CX + iStaticSpace + cnt + iStaticSpace * 2 '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 ariPolyLine = NEW Integer[] ariPolyLine.Resize(Chart.Count * 2) aroPolyLines.Add(ariPolyLine) 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.LinesPercent f += Chart[j][i] / fMaxVal * 100 CASE ChartType.LinesStacked f += Chart[j][i] CASE ELSE f = Chart[j][i] END SELECT aroPolyLines[j][i * 2] = hRect.Left + (hUnits.X * i) aroPolyLines[j][i * 2 + 1] = hRect.Bottom - f * hUnits.Y NEXT NEXT FOR i = 0 TO aroPolyLines.Max 'TO 0 STEP -1 Draw.LineWidth = 2 Draw.ForeColor = Chart.Colors[i] Draw.LineStyle = Line.Solid draw.Polyline(aroPolyLines[i]) NEXT IF $iType = ChartType.LinesSymbols THEN FOR i = 0 TO aroPolyLines.Max FOR j = 0 TO aroPolyLines[i].Max STEP 2 Draw.LineWidth = 1 Draw.FillColor = Chart.Colors[i] Draw.ForeColor = Color.DarkGray MTools.DrawSymbol(i, aroPolyLines[i][j], aroPolyLines[i][j + 1]) NEXT NEXT ENDIF END .