Drawing colored line charts

Started by Stephen, November 20, 2022, 21:43:30

Previous topic - Next topic

Stephen

Has anyone managed to get the SmallBasic CHART and COLOR commands to draw colored line charts?

It's easy enough to draw colored bar charts or colored text using the color or color(RGB) command but the line chart (type 1) seems only capable of drawing a black line on a white background. 

I recall I've also managed to draw colored lines using LINE but not the CHART command.

chrisws

Ideally the chart lines would be drawn in the currently set foreground colour.
It's a simple bug that can be easily fixed.

Stephen

#2
Chrisws

Do you mean change a bug in the source code?
It doesn't matter what the prior background color is set to, the line drawn by the chart command is always black.

This program attempts to print a chart in all the 15 colors on a white then black background, which fails to colorise the line.  It then repeats using the line command which works.  As you can see the black background is far better at distinguishing between colors, but this isn't possible with 'chart' and I need to compare 7 or 8 different graphs
I'll have to re-write using the line command for the time being, but for the amount of points & lines I have it will slow the program.
(Edit, I've made it a bit clearer showing colour with chart doesn't work, whilst color with line does)

demo = [1.5,2,3.5,4,5,6.5,7,8,9.5,10,11,12.5]
FOR Lop= 1 to 2
For background=15 TO 0 STEP -15
  FOR Col=0 TO 15
Color Col, background
  style = 0   
  type = 1
  Cls
    IF Lop=1 THEN Print " Chart Type "; type;" Chart Style "; style; " Color "; Col
    IF Lop=2 THEN Print " Line Command with Color  "; Col
     IF Lop=1 THEN Chart type, demo, style, 150, 150, 750, 550
    IF Lop=2 THEN Line 10,500,1000,500,Col
    DELAY 150
    NEXT Col
    NEXT background
   NEXT Lop
    PRINT ;"Finished"
    END