Area Charts & Streamgraphs

Area Chart

using VegaLite, VegaDatasets

dataset("unemployment-across-industries") |>
@vlplot(
    :area,
    width=300, height=200,
    x={
        "yearmonth(date)",
        axis={format="%Y"}
    },
    y={
        "sum(count)",
        axis={title="count"}
    }
)
20002001200220032004200520062007200820092010date (year-month)05,00010,00015,000count

Area Chart with Gradient

using VegaLite, VegaDatasets

dataset("stocks") |>
@vlplot(
    mark={
        :area,
        line={color="darkgreen"},
        color={
            x1=1,
            y1=1,
            x2=1,
            y2=0,
            gradient=:linear,
            stops=[
                {offset=0,color="white"},
                {offset=1,color="darkgreen"}
            ]
        }
    },
    transform=[{filter="datum.symbol==='GOOG'"}],
    x="date:t",
    y="price:q"
)
200520062007200820092010date0200400600800price

Area Chart with Overlaying Lines and Point Markers

using VegaLite, VegaDatasets

dataset("stocks") |>
@vlplot(
    transform=[{filter="datum.symbol==='GOOG'"}],
    mark={
        :area,
        line=true,
        point=true
    },
    x="date:t",
    y=:price
)
200520062007200820092010date0200400600800price

Stacked Area Chart

using VegaLite, VegaDatasets

dataset("unemployment-across-industries") |>
@vlplot(
    :area,
    width=300, hieght=200,
    x={
        "yearmonth(date)",
        axis={format="%Y"}
    },
    y="sum(count)",
    color={
        :series,
        scale={scheme="category20b"}
    }
)
20002001200220032004200520062007200820092010date (year-month)05,00010,00015,000Sum of countAgricultureBusiness servicesConstructionEducation and HealthFinanceGovernmentInformationLeisure and hospitalityManufacturingMining and ExtractionOtherSelf-employedTransportation and UtilitiesWholesale and Retail Tradeseries

Normalized Stacked Area Chart

using VegaLite, VegaDatasets

dataset("unemployment-across-industries") |>
@vlplot(
    :area,
    width=300, height=200,
    x={
        "yearmonth(date)",
        axis={
            domain=false,
            format="%Y"
        }
    },
    y={
        "sum(count)",
        axis=nothing,
        stack=:normalize
    },
    color={
        :series,
        scale={scheme="category20b"}
    }
)
20002001200220032004200520062007200820092010date (year-month)AgricultureBusiness servicesConstructionEducation and HealthFinanceGovernmentInformationLeisure and hospitalityManufacturingMining and ExtractionOtherSelf-employedTransportation and UtilitiesWholesale and Retail Tradeseries

Streamgraph

using VegaLite, VegaDatasets

dataset("unemployment-across-industries") |>
@vlplot(
    :area,
    width=300, height=200,
    x={
        "yearmonth(date)",
        axis={
            domain=false,
            format="%Y",
            tickSize=0
        }
    },
    y={
        "sum(count)",
        axis=nothing,
        stack=:center
    },
    color={
        :series,
        scale={scheme="category20b"}
    }
)
20002001200220032004200520062007200820092010date (year-month)AgricultureBusiness servicesConstructionEducation and HealthFinanceGovernmentInformationLeisure and hospitalityManufacturingMining and ExtractionOtherSelf-employedTransportation and UtilitiesWholesale and Retail Tradeseries

Horizon Graph

using VegaLite, DataFrames

data = DataFrame(
    x=1:20,
    y=[28,55,43,91,81,53,19,87,52,48,24,49,87,66,17,27,68,16,49,15]
)

data |>
@vlplot(width=300, height=50, config={area={interpolate=:monotone}}) +
@vlplot(
    mark={
        :area,
        clip=true,
        orient=:vertical
    },
    x={:x, scale={zero=false, nice=false}},
    y={:y, scale={domain=[0,50]}},
    opacity={value=0.6}
) +
@vlplot(
    transform=[{calculate="datum.y-50", as=:ny}],
    mark={
        :area,
        clip=true,
        orient=:vertical
    },
    x=:x,
    y={
        "ny:q",
        scale={domain=[0,50]},
        axis={title="y"}
    },
    opacity={value=0.3}
)
2468101214161820x02040y