# stock2

How to download and try this example

    Usage: pl -gif stock2.htm
    Data source: quote.yahoo.com (Spreadsheet format)

    Illustrates use of segment bars, and tics on bars to show opening and
    closing price.  Also illustrates ranging of data using the $inrange() function.

    #proc page
    #if @DEVICE in gif,png
      scale: 0.7
    #endif

    // define top plotting area using proc areadef
    #proc areadef
    title: Trailer Tongue Technologies Corp.
    rectangle: 1 3 5 5
    xscaletype: date dd-mmm-yy
    xrange: 4-Apr-99 1-Jun-99
    yrange: 50 60
    yscaletype: log
    #saveas: A

    // read data file using proc getdata
    #proc getdata
    file: stock.csv
    select: $inrange(@@1,X) = 1
    delimit: comma

    // reverse the record order, since the data is provided in reverse chronological
    // order, using proc processdata
    #proc processdata
    action: reverse

    // set up X axis using proc xaxis
    #proc xaxis
    stubs: inc 7
    stubformat: Mmmdd
    stubrange: 4-Apr-99
    grid: color=skyblue
    #saveas: XAX

    // set up Y axis using proc yaxis
    #proc yaxis
    stubs: inc 2
    grid: color=skyblue

    // draw hi/low/close bars using proc bars
    #proc bars
    locfield: 1
    segmentfields: 3 4	// low and hi
    leftticfield: 2		// open
    rightticfield: 5	// close
    thinbarline: width=0.3 color=green

    // do volume

    // define bottom plotting area using proc areadef
    #proc areadef
    #clone: A
    rectangle: 1 1.6 5 2.6
    yrange: 0 5000000
    yscaletype: linear
    title:

    // set up X axis using proc xaxis
    #proc xaxis
    label: Volume (1000s)
    ticincrement: 7
    labeldetails: adjust=0,0.2 size=8

    // set up Y axis using proc yaxis
    #proc yaxis
    stubs: inc 1000 1000
    grid: color=skyblue

    // render histogram using proc bars
    #proc bars
    barwidth: 0.001
    locfield: 1
    lenfield: 6
    thinbarline: color=green