barchart(n)

๐Ÿ“ฆ version 2.5.3, in nixpkgs unstable

๐Ÿ’– barchart(n) ๐Ÿ’–

Okay so this is the BLT Built-In Commands manual page for barchart, and it is literally giving โ€œplot your X-Y data as barsโ€ main character energy. โœจ


โœจ NAME โœจ

barchart โ€” bar chart for plotting X-Y coordinate data. ๐Ÿ’…


๐ŸŽ€ SYNOPSIS ๐ŸŽ€

barchart pathName ?option value?...

๐ŸŒธ DESCRIPTION ๐ŸŒธ

The barchart command creates a bar chart for plotting two-dimensional data, aka X-Y coordinates. A bar chart is a graphic way to compare numbers by showing bars whose lengths are proportional to the y-coordinates of the points they represent. Bestie, it is so visual. ๐Ÿ’–

The bar chart has many configurable components: coordinate axes, elements, legend, grid lines, cross hairs, etc. They let you customize the look and feel of the graph. Obsessed. ๐ŸŽ€


๐Ÿฆ‹ INTRODUCTION ๐Ÿฆ‹

The barchart command creates a new window for plotting two-dimensional data (X-Y coordinates), using bars of various lengths to represent the data points. The bars are drawn in a rectangular area displayed in the center of the new window. That rectangle is the plotting area. The coordinate axes are drawn in the margins surrounding the plotting area. By default, the legend is drawn in the right margin. The title is displayed in the top margin. Slay. โœจ

A barchart widget has several configurable components: coordinate axes, data elements, legend, grid, cross hairs, pens, postscript, and annotation markers. Each component can be queried or modified. ๐Ÿ‘‘

๐Ÿงญ axis

Up to four coordinate axes โ€” two X-coordinate and two Y-coordinate axes โ€” can be displayed, but you can create and use any number of axes. Axes control what region of data is displayed and how the data is scaled. Each axis consists of the axis line, title, major and minor ticks, and tick labels. Tick labels display the value at each major tick. Iconic. ๐Ÿ’…

๐ŸŽฏ crosshairs

Cross hairs are used to position the mouse pointer relative to the X and Y coordinate axes. Two perpendicular lines, intersecting at the current location of the mouse, extend across the plotting area to the coordinate axes. Itโ€™s giving โ€œwhere am I, exactly?โ€ energy. ๐Ÿฆ‹

๐Ÿ“ element

An element represents a set of data to be plotted. It contains an x and y vector of values representing the data points. Each data point is displayed as a bar where the length of the bar is proportional to the ordinate (Y-coordinate) of the data point. The appearance of the bar, such as its color, stipple, or relief, is configurable. ๐Ÿ’–

A special case exists when two or more data points have the same abscissa (X-coordinate). By default, the bars are overlayed, one on top of the other. The bars are drawn in the order of the element display list. But you can also configure the bars to be displayed in two other ways. They may be displayed as a stack, where each bar (with the same abscissa) is stacked on the previous. Or they can be drawn side-by-side as thin bars. The width of each bar is a function of the number of data points with the same abscissa. No cap, thatโ€™s just how it works. ๐Ÿซถ

๐ŸŒˆ grid

Extends the major and minor ticks of the X-axis and/or Y-axis across the plotting area. Grid lines just understood the assignment. โญ

๐Ÿ‘‘ legend

The legend displays the name and symbol of each data element. The legend can be drawn in any margin or in the plotting area. Queen behavior. ๐ŸŽ€

๐Ÿงš marker

Markers are used to annotate or highlight areas of the graph. For example, you could use a text marker to label a particular data point. Markers come in various forms: text strings, bitmaps, connected line segments, images, polygons, or embedded widgets. So many vibes, so many options. ๐ŸŒธ

๐Ÿ–Š๏ธ pen

Pens define attributes for elements. Data elements use pens to specify how they should be drawn. A data element may use many pens at once. Here the particular pen used for a data point is determined from each elementโ€™s weight vector โ€” see the elementโ€™s -weight and -style options. Iykyk. ๐Ÿ’œ

๐Ÿ“œ postscript

The widget can generate encapsulated PostScript output. This component has several options to configure how the PostScript is generated. Fancy. โœจ


โญ SYNTAX โญ

barchart pathName ?option value?...

The barchart command creates a new window pathName and makes it into a barchart widget. At the time this command is invoked, there must not exist a window named pathName, but pathNameโ€™s parent must exist. Additional options may be specified on the command line or in the option database to configure aspects of the graph such as its colors and font. See the configure operation below for the exact details about what option and value pairs are valid. ๐Ÿ’…

If successful, barchart returns the path name of the widget. It also creates a new Tcl command by the same name. You can use this command to invoke various operations that query or modify the graph. The general form is:

pathName operation ?arg?...

Both operation and its arguments determine the exact behavior of the command. The operations available for the graph are described in the BARCHART OPERATIONS section. ๐Ÿฆ‹

The command can also be used to access components of the graph:

pathName component operation ?arg?...

The operation, now located after the name of the component, is the function to be performed on that component. Each component has its own set of operations that manipulate that component. They will be described below in their own sections. Periodt. ๐Ÿ’–

โœจ EXAMPLE โœจ

Okay bestie, real talk โ€” this is the part everyone actually reads, because the barchart command creates a new bar chart and we're gonna walk through it step by step. ๐Ÿ’…

# Create a new bar chart.  Plotting area is black.
barchart .b -plotbackground black

A brand-new Tcl command called .b just got created, and it's your remote control for the chart โ€” you use it to query stuff and change stuff. Like, say you wanna retitle the graph to "My Plot"? You grab that new command and hit the configure operation. So easy. ๐ŸŽ€

# Change the title.
.b configure -title "My Plot"

To actually add data, you use the command plus the element component. Iconic combo ngl.

# Create a new element named "e1"
.b element create e1 \
  -xdata { 1 2 3 4 5 6 7 8 9 10 } \
  -ydata { 26.18 50.46 72.85 93.31 111.86 128.47 143.14
     155.85 166.60 175.38 }

The element's X-Y coordinates are given as lists of numbers. But alternately? BLT vectors could totally hold those X-Y coordinates instead, and that's a whole vibe. ๐Ÿฆ‹

# Create two vectors and add them to the barchart.
vector xVector yVector
xVector set { 1 2 3 4 5 6 7 8 9 10 }
yVector set { 26.18 50.46 72.85 93.31 111.86 128.47 143.14 155.85
  166.60 175.38 }
n.b element create e1 -xdata xVector -ydata yVector

The whole point of using vectors: when you modify one, the graph automatically redraws itself to reflect the new values. Automatic glow-up, no cap. โœจ

# Change the y coordinate of the first point.
set yVector(0) 25.18

So now you've got an element named e1 living in .b, and it's automatically added to the display list of elements โ€” that list is your control panel for what order elements get drawn in. Wanna peek at it or reset it? That's the element's show operation, bestie.

# Get the current display list
set elemList [.b element show]
# Remove the first element so it won't be displayed.
.b element show [lrange $elemList 0 end]

Your element gets displayed as however many bars as there are data points (in this case, ten of them ๐ŸŽ‰). The bars are drawn centered at the x-coordinate of the data point, and they all share the same attributes (colors, stipple, etc.). Each bar's width is one unit by default โ€” you can change that with the -barwidth option.

# Change the scale of the x-coordinate data
xVector set { 0.2 0.4 0.6 0.8 1.0 1.2 1.4 1.6 1.8 2.0 }
# Make sure we change the bar width too.
.b configure -barwidth 0.2

Each bar's height is proportional to the ordinate (Y-coordinate) of the data point. Math but make it cute. ๐Ÿ“Š


Now, plot twist ๐Ÿซข โ€” if two or more data points have the same abscissa (same X-coordinate value), the bars for those points can be drawn in a few different ways. Default behavior is to overlay the bars, one right on top of the other, and the ordering comes from the element display list. But if you pick stacked mode (via the -barmode configuration option), the bars stack up, each one above the previous. Tower vibes. ๐Ÿ—๏ธ

# Display the elements as stacked.
.b configure -barmode stacked

And if you go with aligned mode instead, bars that share the same x-coordinates get displayed side by side. Each bar's width becomes a fraction of its normal width, based on how many bars share that same x-coordinate. Group photo energy. ๐Ÿ“ธ

# Display the elements side-by-side.
.b configure -barmode aligned

By default, the element's label in the legend is also e1. You can change that label โ€” or just straight up say no legend entry for this one โ€” again using the element's configure operation.

# Don't display "e1" in the legend.
.b element configure e1 -label ""

And you can configure wayyy more than just the label. An element has a ton of attributes โ€” stipple, foreground and background colors, relief, etc. The full menu, fr fr.

.b element configure e1 -fg red -bg pink \
  -stipple gray50

Four coordinate axes get created automatically: x, x2, y, and y2. By default elements are mapped onto the axes x and y, but you can switch that up with the -mapx and -mapy options.

# Map "e1" on the alternate y axis "y2".
.b element configure e1 -mapy y2

Axes can be configured a million ways too โ€” like, you can flip the scale of the Y-axis from linear to log using the axis component. ๐Ÿงฎ

# Y-axis is log scale.
.b axis configure y -logscale yes

One super important thing axes do: zooming in on a particular data region. And zooming is literally just specifying new axis limits with the -min and -max configuration options. That's it. That's the whole trick. ๐Ÿ‘‘

.b axis configure x -min 1.0 -max 1.5
.b axis configure y -min 12.0 -max 55.15

To zoom interactively, you link the axis configure operations up with some user interaction (like pressing the mouse button) using the bind command. And to convert between screen and graph coordinates, hit the invtransform operation.

# Click the button to set a new minimum
bind .b <ButtonPress-1> {
    %W axis configure x -min [%W axis invtransform x %x]
    %W axis configure x -min [%W axis invtransform x %y]
}

By default, the limits of an axis are determined from data values. Wanna go back to the default limits? Set the -min and -max options to the empty value. Reset era. ๐ŸŒธ

# Reset the axes to autoscale again.
.b axis configure x -min {} -max {}
.b axis configure y -min {} -max {}

By default the legend gets drawn in the right margin. You can change that โ€” or any other legend configuration options โ€” using the legend component.

# Configure the legend font, color, and relief
.b legend configure -position left -relief raised \
  -font fixed -fg blue

And to keep the legend from showing up at all, turn on the -hide option.

# Don't display the legend.
.b legend configure -hide yes

The barchart also has simple drawing procedures called markers โ€” they're for highlighting or annotating data in the graph. The types of markers available are bitmaps, polygons, lines, or windows. You could use markers, for example, to mark or brush points. Like, maybe there's a line marker showing some low-water value. Markers are created with the marker operation.

# Create a line represent the low water mark at 10.0
.b marker create line -name "low_water" \
  -coords { -Inf 10.0 Inf 10.0 } \
  -dashes { 2 4 2 } -fg red -bg blue

That creates a line marker named low_water, and it displays a horizontal line stretching all the way across the plotting area at the y-coordinate 10.0. The coordinates -Inf and Inf mean the relative minimum and maximum of the axis (the x-axis in this case, iykyk). By default markers are drawn last, on top of the bars โ€” you can flip that with the -under option.

# Draw the marker before elements are drawn.
.b marker configure low_water -under yes

You can add cross hairs or grid lines using the crosshairs and grid components. Chef's kiss. ๐ŸคŒ

# Display both cross hairs and grid lines.
.b crosshairs configure -hide no -color red
.b grid configure -hide no -dashes { 2 2 }

Finally, to get a hardcopy of the graph, use the postscript component.

# Print the bar chart into file "file.ps"
.b postscript output file.ps -maxpect yes -decorations no

That generates a file file.ps containing the encapsulated PostScript of the graph. The -maxpect option says to scale the plot to the size of the page. And turning off the -decorations option means no borders or color backgrounds get drawn โ€” i.e. the background of the margins, legend, and plotting area will be white. Clean, minimal, aesthetic. ๐Ÿ•Š๏ธ


<divider>

Okay so, continuing on the syntax tea ๐Ÿซ– โ€” barchart pathName ?option value?...

The barchart command creates a new window pathName and makes it into a barchart widget. Important caveat bestie: at the time this command is invoked, there must not already exist a window named pathName โ€” but pathName's parent must exist. Additional options may be specified on the command line or in the option database to configure aspects of the bar chart such as its colors and font. For the exact details as to what option and value pairs are valid, see the configure operation below. ๐Ÿ‘€

If it's successful, barchart returns pathName. It also creates a new Tcl command pathName, and that command may be used to invoke various operations to query or modify the bar chart. It's got the general form:

pathName operation ?arg?...

Both operation and its arguments determine the exact behavior of the command. The operations available for the bar chart are described in the following section. ๐ŸŒˆ

๐Ÿ’– BARCHART OPERATIONS ๐Ÿ’–

okay bestie, this is the part where you actually do stuff to the chart. buckle up ๐ŸŽ€

  • pathName bar elemName ?option value?... โ€” makes a shiny new barchart element called elemName. if an element named elemName already exists? error, sorry babe ๐Ÿ˜ญ. for the tea on which option and value pairs are legal, go read the manual for barchart.
  • pathName cget option โ€” hands you back the current value of the config option named option. and option can be literally any option listed below under configure. iykyk ๐Ÿ’…
  • pathName configure ?option value?... โ€” queries or changes the config options of the graph. three moods:
    • if option isn't given at all โ†’ you get back a list describing all the current options for pathName.
    • if option is given but value isn't โ†’ you get back a list describing just that option.
    • if you give one or more option/value pairs โ†’ for each pair, the option option gets set to value.

and here's the full roster of valid options, no cap โœจ

  • -background color โ€” sets the background color. this covers the margins and the legend, but not the plotting area. the default is the standard background. ๐ŸŽจ
  • -barmode mode โ€” tells it how related bar elements get drawn. "related" = elements whose data points share the same abscissas (X-coordinates). mode says how those segments should be drawn, and it can be infront, aligned, overlap, or stacked. default mode is infront.
    • infront โ€” each successive segment is drawn in front of the previous one. ๐Ÿฅž
    • stacked โ€” each successive segment is stacked vertically on top of the previous one.
    • aligned โ€” segments get displayed aligned from right-to-left.
    • overlap โ€” like aligned but the segments slightly overlap each other. ๐Ÿ™ˆ
  • -barwidth value โ€” specifies how wide the bars are. individual elements can override this with their own -barwidth config option. value is the width in terms of graph coordinates. default width is 1.0. ๐Ÿ“
  • -borderwidth pixels โ€” sets the width of the 3-D border around the outside edge of the widget. the -relief option decides whether that border even gets drawn. default is 2.
  • -bottommargin pixels โ€” specifies the size of the margin below the X-coordinate axis. if pixels is 0, the margin size gets picked automatically. default is 0.
  • -bufferelements boolean โ€” says whether an internal pixmap should be used to buffer the display of data elements. if boolean is true, data elements get drawn to an internal pixmap. this one's lowkey a lifesaver when the graph is redrawn a lot while the data stays the same (think: dragging a marker across the plot). see the SPEED TIPS section. default is 1. โšก
  • -cursor cursor โ€” specifies the widget's cursor. default cursor is crosshair. ๐ŸŽฏ
  • -font fontName โ€” specifies the font of the graph title. default is *-Helvetica-Bold-R-Normal-*-18-180-*.
  • -halo pixels โ€” specifies a maximum distance to consider when searching for the closest data point (see the element's closest operation below). data points further than pixels away are ignored. default is 0.5i. ๐ŸŒ€
  • -height pixels โ€” specifies the requested height of the widget. default is 4i.
  • -invertxy boolean โ€” says whether the placement of the X-axis and Y-axis should be inverted. if boolean is true, X and Y axes get swapped. default is 0. ๐Ÿ”„
  • -justify justify โ€” specifies how the title should be justified. this only matters when the title has more than one line of text. justify must be left, right, or center. default is center.
  • -leftmargin pixels โ€” sets the size of the margin from the left edge of the window to the Y-coordinate axis. if pixels is 0, the size gets calculated automatically. default is 0.
  • -plotbackground color โ€” specifies the background color of the plotting area. default is white. ๐Ÿค
  • -plotborderwidth pixels โ€” sets the width of the 3-D border around the plotting area. the -plotrelief option decides whether a border is drawn. default is 2.
  • -plotpadx pad โ€” sets how much padding gets added to the left and right sides of the plotting area. pad can be a list of one or two screen distances. if pad has two elements, the left side of the plotting area entry gets padded by the first distance and the right side by the second. if pad is just one distance, both left and right sides get padded evenly. default is 8.
  • -plotpady pad โ€” sets how much padding gets added to the top and bottom of the plotting area. pad can be a list of one or two screen distances. if pad has two elements, the top of the plotting area gets padded by the first distance and the bottom by the second. if pad is just one distance, both top and bottom get padded evenly. default is 8.
  • -plotrelief relief โ€” specifies the 3-D effect for the plotting area. relief says how the interior of the plotting area should appear relative to the rest of the graph โ€” for example, raised means the plot should look like it's protruding from the graph, relative to the surface of the graph. default is sunken. ๐Ÿ•ณ๏ธ
  • -relief relief โ€” specifies the 3-D effect for the barchart widget. relief says how the graph should appear relative to the widget it's packed into โ€” for example, raised means the graph should look like it's protruding. default is flat.
  • -rightmargin pixels โ€” sets the margin size from the plotting area to the right edge of the window. by default, the legend gets drawn in this margin. if pixels is less than 1, the margin size gets selected automatically.
  • -takefocus focus โ€” provides the info used when moving focus from window to window via keyboard traversal (like Tab and Shift-Tab). if focus is 0, that means this window should be skipped entirely during keyboard traversal. 1 means this window should always receive the input focus. an empty value means the traversal scripts get to decide whether to focus on the window. default is "". โŒจ๏ธ
  • -tile image โ€” specifies a tiled background for the widget. if image isn't "", the background gets tiled using image. otherwise, the normal background color gets drawn (see the -background option). image must be an image created with the Tk image command. default is "". ๐Ÿ–ผ๏ธ
  • -title text โ€” sets the title to text. if text is "", no title gets displayed. ๐Ÿ‘‘
  • -topmargin pixels โ€” specifies the size of the margin above the x2 axis. if pixels is 0, the margin size gets calculated automatically.
  • -width pixels โ€” specifies the requested width of the widget. default is 5i.
  • pathName crosshairs operation ?arg? โ€” go peek at the CROSSHAIRS COMPONENT section, bestie.
  • pathName element operation ?arg?... โ€” see the ELEMENT COMPONENTS section.
  • pathName extents item โ€” returns the size of a particular item in the graph. item has to be one of leftmargin, rightmargin, topmargin, bottommargin, plotwidth, or plotheight. ๐Ÿ“
  • pathName grid operation ?arg?... โ€” see the GRID COMPONENT section.
  • pathName invtransform winX winY โ€” does an inverse coordinate transformation, mapping window coordinates back to graph coordinates, using the standard X-axis and Y-axis. returns a list containing the X-Y graph coordinates. ๐Ÿ”™
  • pathName inside x y โ€” returns 1 if the designated screen coordinate (x and y) is inside the plotting area, and 0 otherwise. ๐Ÿ’ก
  • pathName legend operation ?arg?... โ€” see the LEGEND COMPONENT section.
  • pathName line operation arg... โ€” this operation is the same as element.
  • pathName marker operation ?arg?... โ€” see the MARKER COMPONENTS section.
  • pathName metafile ?fileName? โ€” โš ๏ธ this operation is for Window platforms only. it creates a Windows enhanced metafile of the barchart. if present, fileName is the file name of the new metafile. otherwise, the metafile gets automatically added to the clipboard. ๐Ÿ“‹
  • pathName postscript operation ?arg?... โ€” see the POSTSCRIPT COMPONENT section.
  • pathName snap photoName โ€” takes a snapshot of the graph and stores the contents in the photo image photoName. photoName is the name of a Tk photo image that must already exist. ๐Ÿ“ธ
  • pathName transform x y โ€” does a coordinate transformation, mapping graph coordinates to window coordinates, using the standard X-axis and Y-axis. returns a list containing the X-Y screen coordinates. ๐Ÿ”œ
  • pathName xaxis operation ?arg?...
  • pathName x2axis operation ?arg?...
  • pathName yaxis operation ?arg?...
  • pathName y2axis operation ?arg?... โ€” see the AXIS COMPONENTS section. (yes, all four of these point you there, they're a package deal ๐Ÿซถ)

๐Ÿฆ‹ BARCHART COMPONENTS ๐Ÿฆ‹

so a graph is literally built out of several components: coordinate axes, data elements, legend, grid, cross hairs, postscript, and annotation markers. and instead of one giant chaotic pile of config options and operations, the graph is partitioned โ€” each component gets its own config options and operations that specifically control that one aspect or part of the graph. it's giving organized main character energy, honestly. โœจ

๐Ÿ’… AXIS COMPONENTS ๐Ÿ’…

okay so bestie, four coordinate axes get created automatically: two X-coordinate axes (x and x2) and two Y-coordinate axes (y, and y2). By default, the axis x is located in the bottom margin, y in the left margin, x2 in the top margin, and y2 in the right margin. ๐Ÿ’–

An axis consists of the axis line, title, major and minor ticks, and tick labels. Major ticks are drawn at uniform intervals along the axis. Each tick is labeled with its coordinate value. Minor ticks are drawn at uniform intervals within major ticks.

The range of the axis controls what region of data is plotted. Data points outside the minimum and maximum limits of the axis are not plotted. By default, the minimum and maximum limits are determined from the data, but you can reset either limit.

You can create and use several axes. To create an axis, invoke the axis component and its create operation.

# Create a new axis called "temperature"
.b axis create temperature

You map data elements to an axis using the element's -mapy and -mapx configuration options. They specify the coordinate axes an element is mapped onto.

# Now map the temperature data to this axis.
.b element create "temp" -xdata $x -ydata $tempData \
    -mapy temperature

While you can have many axes, only four axes can be displayed simultaneously. They are drawn in each of the margins surrounding the plotting area. The axes x and y are drawn in the bottom and left margins. The axes x2 and y2 are drawn in top and right margins. Only x and y are shown by default. Note that the axes can have different scales. ๐Ÿฆ‹

To display a different axis, you invoke one of the following components: xaxis, yaxis, x2axis, and y2axis. The use operation designates the axis to be drawn in the corresponding margin: xaxis in the bottom, yaxis in the left, x2axis in the top, and y2axis in the right.

# Display the axis temperature in the left margin.
.b yaxis use temperature

You can configure axes in many ways. The axis scale can be linear or logarithmic. The values along the axis can either monotonically increase or decrease. If you need custom tick labels, you can specify a Tcl procedure to format the label any way you wish. You can control how ticks are drawn, by changing the major tick interval or the number of minor ticks. You can define non-uniform tick intervals, such as for time-series plots. โœจ

pathName axis cget axisName option

Returns the current value of the option given by option for axisName. Option may be any option described below for the axis configure operation.

pathName axis configure axisName ?axisName?... ?option value?...

Queries or modifies the configuration options of axisName. Several axes can be changed. If option isn't specified, a list describing all the current options for axisName is returned. If option is specified, but not value, then a list describing option is returned. If one or more option and value pairs are specified, then for each pair, the axis option option is set to value. The following options are valid for axes. ๐Ÿ‘‘

  • -autorange range โ€” Sets the range of values for the axis to range. The axis limits are automatically reset to display the most recent data points in this range. If range is 0.0, the range is determined from the limits of the data. If -min or -max are specified, they override this option. The default is 0.0.
  • -color color โ€” Sets the color of the axis and tick labels. The default is black.
  • -command prefix โ€” Specifies a Tcl command to be invoked when formatting the axis tick labels. Prefix is a string containing the name of a Tcl proc and any extra arguments for the procedure. This command is invoked for each major tick on the axis. Two additional arguments are passed to the procedure: the pathname of the widget and the current numeric value of the tick. The procedure returns the formatted tick label. If "" is returned, no label will appear next to the tick. You can get the standard tick labels again by setting prefix to "". The default is "".
Please note that this procedure is invoked while the bar chart is redrawn. You may query the widget's configuration options. But do not reset options, because this can have unexpected results. ๐Ÿ˜ญ
  • -descending boolean โ€” Indicates whether the values along the axis are monotonically increasing or decreasing. If boolean is true, the axis values will be decreasing. The default is 0.
  • -hide boolean โ€” Indicates whether the axis is displayed.
  • -justify justify โ€” Specifies how the axis title should be justified. This matters only when the axis title contains more than one line of text. Justify must be left, right, or center. The default is center.
  • -limits formatStr โ€” Specifies a printf-like description to format the minimum and maximum limits of the axis. The limits are displayed at the top/bottom or left/right sides of the plotting area. FormatStr is a list of one or two format descriptions. If one description is supplied, both the minimum and maximum limits are formatted in the same way. If two, the first designates the format for the minimum limit, the second for the maximum. If "" is given as either description, then that limit will not be displayed. The default is "".
  • -linewidth pixels โ€” Sets the width of the axis and tick lines. The default is 1 pixel.
  • -logscale boolean โ€” Indicates whether the scale of the axis is logarithmic or linear. If boolean is true, the axis is logarithmic. The default scale is linear.
  • -loose boolean โ€” Indicates whether the limits of the axis should fit the data points tightly, at the outermost data points, or loosely, at the outer tick intervals. This is relevant only when the axis limit is automatically calculated. If boolean is true, the axis range is "loose". The default is 0.
  • -majorticks majorList โ€” Specifies where to display major axis ticks. You can use this option to display ticks at non-uniform intervals. MajorList is a list of axis coordinates designating the location of major ticks. No minor ticks are drawn. If majorList is "", major ticks will be automatically computed. The default is "".
  • -max value โ€” Sets the maximum limit of axisName. Any data point greater than value is not displayed. If value is "", the maximum limit is calculated using the largest data value. The default is "".
  • -min value โ€” Sets the minimum limit of axisName. Any data point less than value is not displayed. If value is "", the minimum limit is calculated using the smallest data value. The default is "".
  • -minorticks minorList โ€” Specifies where to display minor axis ticks. You can use this option to display minor ticks at non-uniform intervals. MinorList is a list of real values, ranging from 0.0 to 1.0, designating the placement of a minor tick. No minor ticks are drawn if the -majortick option is also set. If minorList is "", minor ticks will be automatically computed. The default is "".
  • -rotate theta โ€” Specifies how many degrees to rotate the axis tick labels. Theta is a real value representing the number of degrees to rotate the tick labels. The default is 0.0 degrees.
  • -shiftby value โ€” Specifies how much to automatically shift the range of the axis. When the new data exceeds the current axis maximum, the maximum is increased in increments of value. You can use this option to prevent the axis limits from being recomputed at each new time point. If value is 0.0, then no automatic shifting is down. The default is 0.0.
  • -showticks boolean โ€” Indicates whether axis ticks should be drawn. If boolean is true, ticks are drawn. If false, only the axis line is drawn. The default is 1.
  • -stepsize value โ€” Specifies the interval between major axis ticks. If value isn't a valid interval (must be less than the axis range), the request is ignored and the step size is automatically calculated.
  • -subdivisions number โ€” Indicates how many minor axis ticks are to be drawn. For example, if number is two, only one minor tick is drawn. If number is one, no minor ticks are displayed. The default is 2.
  • -tickfont fontName โ€” Specifies the font for axis tick labels. The default is *-Courier-Bold-R-Normal-*-100-*.
  • -ticklength pixels โ€” Sets the length of major and minor ticks (minor ticks are half the length of major ticks). If pixels is less than zero, the axis will be inverted with ticks drawn pointing towards the plot. The default is 0.1i.
  • -title text โ€” Sets the title of the axis. If text is "", no axis title will be displayed.
  • -titlecolor color โ€” Sets the color of the axis title. The default is black.
  • -titlefont fontName โ€” Specifies the font for axis title. The default is *-Helvetica-Bold-R-Normal-*-14-140-*.

Axis configuration options may be also be set by the option command. The resource class is Axis. The resource names are the names of the axes (such as x or x2). ๐ŸŒˆ

                     option add *Barchart.Axis.Color  blue
                     option add *Barchart.x.LogScale  true
                     option add *Barchart.x2.LogScale false

So yeah, once you've set those global vibes, here's the actual ops you can call on axes โœจ

  • pathName axis create axisName ?option value?... โ€” makes a brand new axis named axisName. No cap, there literally cannot already be an axis with that name (it will be a whole thing ๐Ÿ™ˆ). option and value are the exact same goodies described up in the axis configure operation.
  • pathName axis delete ?axisName?... โ€” yeets the named axes. But bestie, listen: an axis isn't really deleted until it's no longer in use, so it's totally safe to delete axes that are mapped to elements ๐Ÿ’…
  • pathName axis invtransform axisName value โ€” does the inverse transformation: takes the screen coordinate value and gives you back the graph coordinate, mapped through axisName. Returns the graph coordinate. It's giving reverse-uno ๐Ÿฆ‹
  • pathName axis limits axisName โ€” returns a list of the min and max limits for axisName. Order is min max. Iconic, orderly, we love to see it.
  • pathName axis names ?pattern?... โ€” returns a list of axes matching zero or more patterns. Give it no pattern argument at all and you get the names of literally every axis ๐ŸŒธ
  • pathName axis transform axisName value โ€” transforms the coordinate value into a screen coordinate by mapping it to axisName. Returns the transformed screen coordinate. The forward version, the main character of the two ๐Ÿ”ฅ
โญ Fun structural fact: only four axes can be displayed at once. By default they're x, y, x2, and y2. Wanna swap one out? Use the use operation on the special axis components: xaxis, x2axis, yaxis, and y2axis. Periodt.
              .g create axis temp
              .g create axis time
              ...
              .g xaxis use temp
              .g yaxis use time

Only the axes you specifically pick for use are the ones shown on screen. No extras crashing the party ๐Ÿ’€

The xaxis, x2axis, yaxis, and y2axis components work on an axis location instead of one specific axis like the more general axis component does. So xaxis manages the X-axis chillin' in the bottom margin (whichever axis that happens to be). Same energy: yaxis = the Y-axis in the left margin, x2axis = the top X-axis, y2axis = the right Y-axis ๐ŸŽ€

They implicitly control whatever axis is currently occupying that location. Defaults: xaxis uses x, yaxis uses y, x2axis uses x2, and y2axis uses y2. Ngl these are way more convenient than constantly figuring out which axes are currently being displayed. Lowkey a lifesaver ๐Ÿซถ

These operations below are available for axes, and they mirror exactly the operations of the axis component. The axis argument has to be xaxis, x2axis, yaxis, or y2axis โ€” no substitutions, bestie.

  • pathName axis cget option
  • pathName axis configure ?option value?...
  • pathName axis invtransform value
  • pathName axis limits
  • pathName axis transform value
  • pathName axis use ?axisName? โ€” designates that the axis axisName is to be displayed at this location. Important: axisName can't already be in use at another location (one axis, one spot, we don't share ๐Ÿ’…). This command returns the name of the axis currently using this location.

๐Ÿฆ‹ CROSSHAIRS COMPONENT ๐Ÿฆ‹

OK so cross hairs = two intersecting lines, one vertical and one horizontal, drawn completely across the plotting area. Their whole job is helping you position the mouse in relation to the coordinate axes. And here's the tea: cross hairs are NOT like line markers, because they're implemented using XOR drawing primitives ๐Ÿ’€ which means they can be drawn and erased super fast without redrawing the entire widget. Efficiency queen ๐Ÿ‘‘

The following operations are available for cross hairs:

  • pathName crosshairs cget option โ€” returns the current value of the cross hairs configuration option you name. Option can be any option described below for the cross hairs configure operation.
  • pathName crosshairs configure ?option value?... โ€” queries or modifies the configuration options of the cross hairs. If option isn't specified, you get a list describing all the current options for the cross hairs. If option is specified but value isn't, you get a list describing that option. If one or more option and value pairs are specified, then for each pair the cross hairs option option is set to value. Here's what's available:

โœจ Cross hairs options โœจ

  • -color color โ€” sets the color of the cross hairs. The default is black. Classic, moody, always works ๐Ÿ–ค
  • -dashes dashList โ€” sets the dash style of the cross hairs. DashList is a list of up to 11 numbers that alternately represent the lengths of the dashes and gaps on the cross hair lines. Each number must be between 1 and 255. If dashList is "", the cross hairs will be solid lines ๐ŸŒˆ
  • -hide boolean โ€” indicates whether cross hairs are drawn. If boolean is true, cross hairs are not drawn. The default is yes. (Yes bestie, the default is hidden โ€” that's the actual documented default, I don't make the rules ๐Ÿ™ˆ)
  • -linewidth pixels โ€” sets the width of the cross hair lines. The default is 1. Skinny legend ๐ŸŽ€
  • -position pos โ€” specifies the screen position where the cross hairs intersect. Pos must be in the form "@x,y", where x and y are the window coordinates of the intersection.

Cross hairs configuration options can also be set with the option command. The resource name and class are crosshairs and Crosshairs respectively ๐Ÿ’œ

                     option add *Barchart.Crosshairs.LineWidth 2
                     option add *Barchart.Crosshairs.Color     red
  • pathName crosshairs off โ€” turns off the cross hairs. Bye bestie ๐Ÿ‘‹
  • pathName crosshairs on โ€” turns on the display of the cross hairs. She's back โœจ
  • pathName crosshairs toggle โ€” toggles the current state of the cross hairs, alternately mapping and unmapping them. The indecisive icon we all relate to ๐Ÿ’€

๐ŸŒธ ELEMENTS ๐ŸŒธ

A data element represents a set of data. It holds x and y vectors, which are the coordinates of the data points. Elements get displayed as bars, where the length of the bar is proportional to the ordinate of the data point โ€” that's literally the whole barchart concept, iykyk ๐Ÿ”ฅ Elements also control how the data looks: color, stipple, relief, etc. Main character energy for your data ๐Ÿ’…

When new data elements are created, they're automatically added to a list of displayed elements. That display list controls which elements get drawn and in what order. The order is the vibe check for your whole chart, so be mindful ๐ŸŽ€

The following operations are available for elements.

  • pathName element activate elemName ?index?... โ€” specifies the data points of element elemName to be drawn using the active foreground and background colors. ElemName is the name of the element and index is a number representing the index of the data point. If no indices are present, then all data points become active ๐Ÿซถ
  • pathName element bind tagName ?sequence? ?command? โ€” associates command with tagName so that whenever the event sequence given by sequence occurs for an element with this tag, command gets invoked. The syntax is similar to the bind command, except it operates on graph elements rather than widgets. See the bind manual entry for the complete details on sequence and the substitutions performed on command before invoking it.

Give it all the arguments and a new binding is created, replacing any existing binding for the same sequence and tagName. If the first character of command is +, then command augments an existing binding instead of replacing it (the plus is the "and also" of it all โœจ). No command argument? Then you get the command currently associated with tagName and sequence (and it's an error if there's no such binding ๐Ÿ™ˆ). Missing both command and sequence? Then you get a list of all the event sequences for which bindings have been defined for tagName.

  • pathName element cget elemName option โ€” returns the current value of the element configuration option given by option. Option can be any of the options described below for the element configure operation.
  • pathName element closest x y ?option value?... ?elemName?... โ€” finds the data point representing the bar closest to the window coordinates x and y in element elemName. ElemName is the name of an element, and it must be displayed, no exceptions. If no elements are specified, then all displayed elements get searched ๐Ÿ‘‘ It returns a list with the name of the closest element, the index of its closest point, and the graph coordinates of the point. If no data point within the threshold distance can be found, "" is returned. Options below:
    • -halo pixels โ€” specifies a threshold distance where selected data points are ignored. Pixels is a valid screen distance, like 2 or 1.2i. If you don't specify this option, it defaults to the value of the barchart's -halo option. Respect the personal space of your data points ๐Ÿ’…
  • pathName element configure elemName ?elemName... ?option value?... โ€” queries or modifies the configuration options for elements. Several elements can be modified at the same time, because we multitask ๐Ÿ’– If option isn't specified, a list describing all the current options for elemName is returned. If option is specified but not value, then a list describing that option is returned. If one or more option and value pairs are specified, then for each pair, the element option option is set to value. The following options are valid for elements:
    • -activepen penName โ€” specifies the pen to use to draw the active element. If penName is "", no active elements will be drawn. The default is activeLine.
    • -bindtags tagList โ€” specifies the binding tags for the element. TagList is a list of binding tag names. Those tags and their order determine how events for elements are handled. Each tag in the list matching the current event sequence will have its Tcl command executed. Implicitly, the name of the element is always the first tag in the list. The default value is all.
    • -background color โ€” sets the color of the border around each bar. The default is white. (Yes, the border color option is called -background. Don't ask, just accept ๐Ÿซ )
    • -barwidth value โ€” specifies the width of the bars drawn for the element. Value is the width in X-coordinates. If this option isn't specified, the width of each bar is the value of the widget's -barwidth option. Consistency is cute ๐Ÿ’…
    • -baseline value โ€” specifies the baseline of the bar segments. This affects how bars are drawn, since bars are drawn from their respective y-coordinate to the baseline. By default the baseline is 0.0. Ground level, bestie ๐ŸŒ
  • -borderwidth pixels โ€” how thick that 3-D border hugging the outside of each bar is gonna be ๐Ÿ’…. Whether the border gets drawn at all is a -relief thing, so don't come for me. pixels has to be a legit screen distance, like 2 or 0.25i. Default? 2. Cute.
  • -data coordList โ€” the actual X-Y coords of your data, bestie. coordList is a list of numeric expressions that spell out the X-Y coordinate pairs of each and every data point.
  • -foreground color โ€” sets the color of the inside of the bars. The vibes, essentially.
  • -hide boolean โ€” says whether the element is displayed or not. Default is no.
  • -label text โ€” the element's label in the legend ๐Ÿท๏ธ. If text is "", your element gets no entry in the legend at all, ghosted. Default label is just the element's own name.
  • -mapx xAxis โ€” picks which X-axis the element's X-coordinates get mapped onto. xAxis has to be the name of an axis. Default is x.
  • -mapy yAxis โ€” same deal but for Y: picks the Y-axis the element's Y-coordinates get mapped onto. yAxis must be the name of an axis. Default is y.
  • -relief string โ€” the 3-D effect you want for the bars โœจ. relief describes how the interior of the bar should appear relative to the surface of the chart โ€” like, raised means the bar should look like it's protruding out of the surface of the plotting area. Default is raised.
  • -stipple bitmap โ€” a stipple pattern to draw the bars with. If bitmap is "", the bar gets drawn solid instead. Both are valid looks, no judgment.
  • -xdata xVector โ€” the x-coordinate vector of your data. xVector is the name of a BLT vector or a list of numeric expressions.
  • -ydata yVector โ€” the y-coordinate vector of your data. yVector is the name of a BLT vector or a list of numeric expressions.

Element configuration options can also be set through the option command, iykyk. The resource names in the option database get prefixed with elem:

option add *Barchart.Element.background blue

Bestie, now the actual element subcommands, aka the whole reason you're here ๐Ÿซถ:

  • pathName element create elemName ?option value?... โ€” makes a brand new element called elemName. Element names have to be unique, so an elemName that already exists is a no-go ๐Ÿ™…. If you pass extra arguments after it, they specify any of the element options that are valid for the element configure operation.
  • pathName element deactivate pattern... โ€” deactivates every element matching pattern for the graph. Elements whose names match any of the patterns you gave get redrawn using their normal colors. Un-deactivated, glowing again ๐Ÿ’–.
  • pathName element delete ?pattern?... โ€” deletes every element matching pattern for the graph. Elements whose names match any of the given patterns are deleted, periodt. The graph gets redrawn without the deleted elements.
  • pathName element exists elemName โ€” returns 1 if an element called elemName currently exists, and 0 otherwise. vibe check โœ….
  • pathName element names ?pattern?... โ€” returns the elements matching one or more pattern. If you give no pattern at all, you get the names of every element back. the whole group chat.
  • pathName element show ?nameList? โ€” queries or modifies the element display list. The element display list decides which elements get drawn and in what order ๐Ÿ‘‘. nameList is a list of elements to be displayed in the order they're named. If there's no nameList argument, you just get the current display list returned.
  • pathName element type elemName โ€” returns the type of elemName. If the element is a bar element, the command returns the string "bar"; otherwise it returns "line".

โœจ GRID COMPONENT โœจ

Grid lines extend from the major and minor ticks of each axis, horizontally or vertically, across the plotting area ๐ŸŒ. Here's what you can do with grid lines:

  • pathName grid cget option โ€” returns the current value of the grid line configuration option given by option. option may be any option described below for the grid configure operation.
  • pathName grid configure ?option value?... โ€” queries or modifies the configuration options for grid lines. If option isn't specified, you get back a list describing all the current grid options for pathName. If option is specified but there's no value, then you get a list describing that option. And if you pass one or more option and value pairs, then for each pair the grid line option option is set to value. These are the options that are valid for grid lines ๐Ÿ‘‡
    • -color color โ€” sets the color of the grid lines. Default is black.
    • -dashes dashList โ€” sets the dash style of the grid lines. dashList is a list of up to 11 numbers that alternately represent the lengths of the dashes and the gaps on the grid lines. Each number must be between 1 and 255. If dashList is "", the grid will be solid lines.
    • -hide boolean โ€” says whether the grid should be drawn. If boolean is true, grid lines are not shown. Default is yes.
    • -linewidth pixels โ€” sets the width of the grid lines. Default width is 1.
    • -mapx xAxis โ€” specifies the X-axis to display grid lines for. xAxis must be the name of an axis, or "" for no grid lines. Default is "".
    • -mapy yAxis โ€” specifies the Y-axis to display grid lines for. yAxis must be the name of an axis, or "" for no grid lines. Default is y.
    • -minor boolean โ€” says whether the grid lines should be drawn for minor ticks. If boolean is true, the lines will appear at minor tick intervals. Default is 1.

Grid configuration options can also be set with the option command. The resource name and class are grid and Grid respectively ๐ŸŽ€:

option add *Barchart.grid.LineWidth 2
option add *Barchart.Grid.Color     black
  • pathName grid off โ€” turns off the display of the grid lines. bye grid ๐Ÿ‘‹
  • pathName grid on โ€” turns on the display of the grid lines. hi grid ๐Ÿ‘‹
  • pathName grid toggle โ€” toggles the display of the grid. indecisive icon behavior.

๐Ÿฆ‹ LEGEND COMPONENT ๐Ÿฆ‹

The legend displays a list of the data elements. Each entry consists of the element's symbol and its label. The legend can appear in any margin (the default location is in the right margin), and it can also be positioned anywhere within the plotting area ๐Ÿ—บ๏ธ.

The following operations are valid for the legend:

  • pathName legend activate pattern... โ€” selects legend entries to be drawn using the active legend colors and relief. Every entry whose element name matches pattern is selected. To count as selected, the element name only has to match one pattern.
  • pathName legend bind tagName ?sequence? ?command? โ€” associates command with tagName so that whenever the event sequence given by sequence occurs for a legend entry with this tag, command gets invoked. Implicitly, the element names in the entry are tags. The syntax is similar to the bind command, except it operates on legend entries instead of widgets. See the bind manual entry for the complete details on sequence and the substitutions performed on command before it's invoked ๐Ÿ“š.

If all arguments are specified, then a new binding is created, replacing any existing binding for the same sequence and tagName. If the first character of command is +, then command augments an existing binding instead of replacing it. If no command argument is provided, then the command currently associated with tagName and sequence is returned (it's an error if there's no such binding ๐Ÿ™ˆ). If both command and sequence are missing, then you get a list of all the event sequences for which bindings have been defined for tagName.

  • pathName legend cget option โ€” returns the current value of a legend configuration option. option may be any option described below in the legend configure operation.
  • pathName legend configure ?option value?... โ€” queries or modifies the configuration options for the legend. If option isn't specified, a list describing the current legend options for pathName is returned. If option is specified but not value, then a list describing option is returned. If one or more option and value pairs are specified, then for each pair the legend option option is set to value. The following options are valid for the legend:
    • -activebackground color โ€” sets the background color for active legend entries. All legend entries marked active (see the legend activate operation) are drawn using this background color.
    • -activeborderwidth pixels โ€” sets the width of the 3-D border around the outside edge of the active legend entries. Default is 2.
    • -activeforeground color โ€” sets the foreground color for active legend entries. All legend entries marked as active (see the legend activate operation) are drawn using this foreground color.
    • -activerelief relief โ€” specifies the 3-D effect you want for active legend entries. relief denotes how the interior of the entry should appear relative to the legend โ€” for example, raised means the entry should appear to protrude from the legend, relative to the surface of the legend. Default is flat.
    • -anchor anchor โ€” tells how to position the legend relative to the positioning point for the legend. This is dependent on the value of the -position option. Default is center.
      • left or right โ€” the anchor describes how to position the legend vertically.
      • top or bottom โ€” the anchor describes how to position the legend horizontally.
  • @x,y โ€” this one's the vibe positioning situation ๐Ÿ’… your anchor tells the legend how to sit relative to wherever you're pointing it. Like, if anchor is center then the legend is centered right on that point; if anchor is n then it gets drawn so that the top-center point of the rectangular region the legend occupies lands exactly on your positioning point. Iconic, precise, no notes. โœจ
    • plotarea โ€” same energy but the anchor is now relative to the plotting area itself. So anchor center = legend centered in the plotting area, anchor ne = legend drawn so it occupies the upper right corner of the plotting area. ๐Ÿซถ
  • -background color โ€” sets the background color of the legend. And if color is "", your legend background is transparent. Glass skin legend, literally. ๐Ÿฆ‹
  • -bindtags tagList โ€” sets the binding tags for legend entries. tagList is a list of binding tag names, and those tags plus their order are what decide how events for legend entries go down. Every tag in the list that matches the current event sequence gets its Tcl command executed. Default value? all. Periodt. ๐Ÿ‘‘
  • -borderwidth pixels โ€” sets the width of the 3-D border around the outside edge of the legend (only if such a border is being drawn at all โ€” the relief option is the one calling the shots there). Default is 2 pixels. ๐ŸŽ€
  • -font fontName โ€” fontName specifies the font used when drawing the labels of each element into the legend. Default is *-Helvetica-Bold-R-Normal-*-12-120-*. She's got a signature look, okay? ๐Ÿ’…
  • -foreground color โ€” sets the foreground color of the text drawn for the element's label. Default is black. Classic, timeless, ate. ๐Ÿ–ค
  • -hide boolean โ€” says whether the legend should be displayed at all. If boolean is true, the legend will not be drawn. Default is no. Ghosting your legend is valid ๐Ÿ’€
  • -ipadx pad โ€” sets how much internal padding gets added to the width of each legend entry. pad can be a list of one or two screen distances. Two elements? Left side of the legend entry gets padded by the first distance and the right side by the second. Just one distance? Both left and right get padded evenly. Default is 2. ๐ŸŒธ
  • -ipady pad โ€” same but for the height of each legend entry. pad can be one or two screen distances โ€” two elements means top padded by the first and bottom by the second; one distance means top and bottom get padded evenly. Default is 2. Matching set bestie ๐ŸŽ€
  • -padx pad โ€” sets the padding on the left and right exteriors of the legend. pad can be one or two screen distances: two elements = left side padded by the first distance, right side by the second; one distance = both sides padded evenly. Default is 4. ๐Ÿฆ‹
  • -pady pad โ€” sets the padding above and below the legend. Again, one or two screen distances โ€” two elements means the area above is padded by the first distance and the area below by the second; one distance means top and bottom areas get padded evenly. Default is 0. โญ
  • -position pos โ€” specifies where the legend is drawn, and heads up, the -anchor option also affects where it lands. So: if pos is left, left, top, or bottom, the legend is drawn in the specified margin. If pos is plotarea, then the legend is drawn inside the plotting area at a particular anchor. And if pos is in the form @x,y, where x and y are window coordinates, the legend is drawn in the plotting area at those coordinates. Default is right. ๐ŸŒˆ
  • -raised boolean โ€” indicates whether the legend is above or below the data elements. This only matters if the legend is inside the plotting area, iykyk. If boolean is true, the legend gets drawn on top of any elements it may overlap. Default is no. ๐Ÿซถ
  • -relief relief โ€” specifies the 3-D effect for the border around the legend. relief says how the interior of the legend should appear relative to the bar chart โ€” for example, raised means the legend should look like it's protruding from the bar chart, relative to the bar chart's surface. Default is sunken. ๐Ÿ’…

Legend configuration options may also be set by the option command. The resource name and class are legend and Legend respectively. Yes bestie, capital L for the class. ๐Ÿ˜Œ

option add *Barchart.legend.Foreground blue
option add *Barchart.Legend.Relief     raised

๐ŸŒธ pathName legend deactivate pattern...

Selects legend entries to be drawn using the normal legend colors and relief. Every entry whose element name matches pattern gets selected. Important tiny rule: to be selected, the element name must match only one pattern. No double-dipping ๐Ÿซถ

โญ pathName legend get pos

Returns the name of the element whose entry is at the screen position pos in the legend. pos must be in the form @x,y, where x and y are window coordinates. If those coordinates don't lie over a legend entry, you get "" back. Polite little empty string, no drama. ๐Ÿ™ˆ


๐Ÿ–Š๏ธ PEN COMPONENTS

Okay so pens. Pens define attributes for elements โ€” they mirror the configuration options of data elements that are all about how symbols and lines get drawn. Data elements use pens to figure out how they're drawn. And a data element can use several pens at once โ€” in which case the pen for a particular data point comes from that element's weight vector (peep the element's -weight and -style options). ๐ŸŽจ

One pen called activeBar is automatically created, and it's used as the default active pen for elements. So basically you can change the active attributes for all elements by just reconfiguring this one pen. Group-chat announcement energy:

.g pen configure "activeBar" -fg green -bg green4

You can create and use several pens too. To create one, invoke the pen component and its create operation:

.g pen create myPen

You map pens to a data element using either the element's -pen or -activepen options:

.g element create "e1" -xdata $x -ydata $tempData \
    -pen myPen

And an element can use several pens at once โ€” you do that by specifying the name of the pen in the element's style list (see the -styles option):

.g element configure "e1" -styles { myPen 2.0 3.0 }

Which is saying: any data point with a weight between 2.0 and 3.0 gets drawn using the pen myPen, and all the other points get drawn with the element's default attributes. We love a range. We love the assignment. โœจ

The following operations are available for pen components.

๐Ÿฆ‹ pathName pen cget penName option

Returns the current value of the option given by option for penName. option may be any option described below for the pen configure operation. ๐Ÿ’–

๐ŸŒŸ pathName pen configure penName ?penName... ?option value?...

Queries or modifies the configuration options of penName. Several pens can be modified at once, bestie โ€” batch it. If option isn't specified, you get back a list describing the current options for penName. If option is specified but no value, you get a list describing option. And if one or more option and value pairs are specified, then for each pair the pen option option is set to value. The following options are valid for pens:

  • -background color โ€” sets the color of the border around each bar. Default is white. ๐ŸŽ€
  • -borderwidth pixels โ€” sets the border width of the 3-D border drawn around the outside of each bar. The -relief option decides if such a border is drawn at all. pixels must be a valid screen distance like 2 or 0.25i. Default is 2. ๐Ÿ“
  • -foreground color โ€” sets the color of the interior of the bars. The main character of the bar, honestly. ๐Ÿ‘‘
  • -relief string โ€” specifies the 3-D effect desired for bars. relief indicates how the interior of the bar should appear relative to the surface of the chart โ€” e.g. raised means the bar should appear to protrude from the bar chart, relative to the surface of the plotting area. Default is raised. ๐Ÿ”ฅ
  • -stipple bitmap โ€” specifies a stipple pattern used to draw the bars. If bitmap is "", then the bar is drawn in a solid fashion. Clean, unfiltered, solid. ๐Ÿ’…
  • -type elemType โ€” specifies the type of element the pen is to be used with. โš ๏ธ This option should only be employed when creating the pen. It's for those of you who wish to mix different types of elements (like bars and lines) on the same graph. The default type is "bar". ๐Ÿซถ

Pen configuration options may also be set by the option command. The resource class is Pen. The resource names are the names of the pens. Get specific, bestie:

option add *Barchart.Pen.Foreground   blue
option add *Barchart.activeBar.foreground  green

๐Ÿ’œ pathName pen create penName ?option value?...

Creates a new pen by the name penName. No pen with the same name can already exist โ€” names are taken, sorry gorgeous. option and value are described above in the pen configure operation. ๐ŸŒธ

๐Ÿงš pathName pen delete ?penName?...

Deletes the named pens. And here's the slay: a pen isn't really deleted until it's no longer in use, so it's totally safe to delete pens that are mapped to elements. Graceful exit, we stan. โœจ

๐ŸŒˆ pathName pen names ?pattern?...

Returns a list of pens matching zero or more patterns. If no pattern argument is given, you get the names of all the pens. Roll call! ๐Ÿ“‹

๐Ÿ–จ๏ธ POSTSCRIPT COMPONENT

okay so your barchart can literally generate encapsulated PostScript output and that is such a serve ๐Ÿ’…. There are a bunch of configuration options you can set to control how the plot gets generated โ€” you can change the page dimensions and the borders, and the plot itself can be scaled, centered, or rotated to landscape. The PostScript output can be written directly to a file, or returned through the interpreter. Choose your fighter, bestie โœจ

The following postscript operations are available.

the postscript operations ๐ŸŽ€

  • pathName postscript cget option โ€” returns the current value of the postscript option given by option. Option can be any option described below for the postscript configure operation. slay, straightforward ๐Ÿซถ
  • pathName postscript configure ?option value?... โ€” queries or modifies the configuration options for PostScript generation. Real talk, here's how it goes down: if option isn't specified, a list describing the current postscript options for pathName is returned. If option is specified but value isn't, then a list describing option is returned. And if one or more option and value pairs are specified, then for each pair, the postscript option option is set to value. easy peasy ๐ŸŒธ

the postscript options, one by one ๐Ÿ‘‘

  • -center boolean โ€” indicates whether the plot should be centered on the PostScript page. If boolean is false, the plot gets placed in the upper left corner of the page instead (humble, lowkey tucked in the corner energy). The default is 1.
  • -colormap varName โ€” VarName must be the name of a global array variable that specifies a color mapping from the X color name to PostScript. Each element of varName must consist of PostScript code to set a particular color value (e.g. 1.0 1.0 0.0 setrgbcolor). When generating color information in PostScript, the array variable varName is checked to see if an element of the name as the color exists. If so, it uses its value as the PostScript command to set the color. If this option hasn't been specified, or if there isn't an entry in varName for a given color, then it uses the red, green, and blue intensities from the X color. iykyk ๐ŸŽจ
  • -colormode mode โ€” specifies how to output color information. Mode must be either color (for full color output), gray (convert all colors to their gray-scale equivalents) or mono (convert foreground colors to black and background colors to white). The default mode is color. full rainbow or full sad-beige, your call ๐ŸŒˆ
  • -fontmap varName โ€” VarName must be the name of a global array variable that specifies a font mapping from the X font name to PostScript. Each element of varName must consist of a Tcl list with one or two elements: the name and point size of a PostScript font. When outputting PostScript commands for a particular font, the array variable varName is checked to see if an element by the specified font exists. If there is such an element, then the font information contained in that element is used in the PostScript output. (If the point size is omitted from the list, the point size of the X font is used.) Otherwise the X font is examined in an attempt to guess what PostScript font to use. This works only for fonts whose foundry property is Adobe (such as Times, Helvetica, Courier, etc.). If all of this fails then the font defaults to Helvetica-Bold. it really said "if I don't know her, I'm guessing, and if I'm still guessing, she's Helvetica-Bold periodt" ๐Ÿ’€
  • -decorations boolean โ€” indicates whether PostScript commands to generate color backgrounds and 3-D borders will be output. If boolean is false, the graph background will be white and no 3-D borders will be generated. The default is 1.
  • -height pixels โ€” sets the height of the plot. This lets you print the bar chart with a height different from the one drawn on the screen. If pixels is 0, the height is the same as the widget's height. The default is 0.
  • -landscape boolean โ€” if boolean is true, this specifies the printed area is to be rotated 90 degrees. In non-rotated output the X-axis of the printed area runs along the short dimension of the page (portrait orientation); in rotated output the X-axis runs along the long dimension of the page (landscape orientation). Defaults to 0. sideways slay ๐Ÿ”ฅ
  • -maxpect boolean โ€” indicates to scale the plot so that it fills the PostScript page. The aspect ratio of the barchart is still retained (no stretching, we are NOT doing that to her). The default is 0.
  • -padx pad โ€” sets the horizontal padding for the left and right page borders. The borders are exterior to the plot. Pad can be a list of one or two screen distances. If pad has two elements, the left border is padded by the first distance and the right border by the second. If pad has just one distance, both the left and right borders are padded evenly. The default is 1i.
  • -pady pad โ€” sets the vertical padding for the top and bottom page borders. The borders are exterior to the plot. Pad can be a list of one or two screen distances. If pad has two elements, the top border is padded by the first distance and the bottom border by the second. If pad has just one distance, both the top and bottom borders are padded evenly. The default is 1i.
  • -paperheight pixels โ€” sets the height of the postscript page. This can be used to select between different page sizes (letter, A4, etc). The default height is 11.0i. ๐Ÿ“„
  • -paperwidth pixels โ€” sets the width of the postscript page. This can be used to select between different page sizes (letter, A4, etc). The default width is 8.5i.
  • -width pixels โ€” sets the width of the plot. This lets you generate a plot of a width different from that of the widget. If pixels is 0, the width is the same as the widget's width. The default is 0.
ngl, postscript configuration options may also be set by the option command. The resource name and class are postscript and Postscript respectively. like so ๐Ÿ‘‡
option add *Barchart.postscript.Decorations false
option add *Barchart.Postscript.Landscape   true

outputting the actual file ๐Ÿ–จ๏ธโœจ

  • pathName postscript output ?fileName? ?option value?... โ€” outputs a file of encapsulated PostScript. If a fileName argument isn't present, the command returns the PostScript. If any option-value pairs are present, they set configuration options controlling how the PostScript is generated. Option and value can be anything accepted by the postscript configure operation above. iconic behavior honestly ๐Ÿ’–

๐Ÿ“ MARKER COMPONENTS

Markers are simple drawing procedures used to annotate or highlight areas of the graph โ€” think little sticky notes but make it graphics ๐ŸŽ€. Markers have various types: text strings, bitmaps, images, connected lines, windows, or polygons.

They can be associated with a particular element, so that when the element is hidden or un-hidden, so is the marker. ride or die, basically ๐Ÿซถ. By default, markers are the last items drawn, so that data elements will appear behind them. You can change this by configuring the -under option.

Markers, in contrast to elements, don't affect the scaling of the coordinate axes โ€” no cap, they just vibe on top ๐Ÿฆ‹. They can also have elastic coordinates (specified by -Inf and Inf respectively) that translate into the minimum or maximum limit of the axis. For example, you can place a marker so it always remains in the lower left corner of the plotting area, by using the coordinates -Inf,-Inf. she stays anchored, she stays unbothered ๐Ÿ’…

The following operations are available for markers.

the marker operations ๐ŸŒธ

  • pathName marker after markerId ?afterId? โ€” changes the order of the markers, drawing the first marker after the second. If no second afterId argument is specified, the marker is placed at the end of the display list. This command can be used to control how markers are displayed, since markers are drawn in the order of this display list. line cutters, but for markers ๐Ÿ˜ญ
  • pathName marker before markerId ?beforeId? โ€” changes the order of the markers, drawing the first marker before the second. If no second beforeId argument is specified, the marker is placed at the beginning of the display list. This command can be used to control how markers are displayed, since markers are drawn in the order of this display list.
  • pathName marker bind tagName ?sequence? ?command? โ€” associates command with tagName such that whenever the event sequence given by sequence occurs for a marker with this tag, command will be invoked. The syntax is similar to the bind command except that it operates on graph markers, rather than widgets. See the bind manual entry for complete details on sequence and the substitutions performed on command before invoking it. โœจ

If all arguments are specified then a new binding is created, replacing any existing binding for the same sequence and tagName. If the first character of command is + then command augments an existing binding rather than replacing it. If no command argument is provided then the command currently associated with tagName and sequence (it's an error if there's no such binding) is returned. If both command and sequence are missing then a list of all the event sequences for which bindings have been defined for tagName is returned. so many modes, she's versatile ๐Ÿ‘‘

  • pathName marker cget option โ€” returns the current value of the marker configuration option given by option. Option may be any option described below in the configure operation. ๐ŸŽ€
  • pathName marker configure markerId ?option value?... โ€” queries or modifies the configuration options for markers. If option isn't specified, a list describing the current options for markerId is returned. If option is specified but not value, then a list describing option is returned. If one or more option and value pairs are specified, then for each pair, the marker option option is set to value. you already know the drill bestie ๐Ÿ’–

okay so the following options are valid for all markers. Each type of marker also has its own type-specific options โ€” they're described in the sections below, bestie. ๐Ÿ’…

  • -bindtags tagList โ€” Specifies the binding tags for the marker. tagList is a list of binding tag names. The tags and their order determine how events for markers are handled. Each tag in the list matching the current event sequence will have its Tcl command executed. Implicitly, the name of the marker is always the first tag in the list. The default value is all.
  • -coords coordList โ€” Specifies the coordinates of the marker. coordList is a list of graph coordinates. The number of coordinates required depends on the type of marker. Text, image, and window markers need only two coordinates (an X-Y coordinate). Bitmap markers can take either two or four coordinates (if four, they represent the corners of the bitmap). Line markers need at least four coordinates, polygons at least six. If coordList is "", the marker will not be displayed. The default is "".
  • -element elemName โ€” Links the marker with the element elemName. The marker is drawn only if the element is also currently displayed (see the element's show operation). If elemName is "", the marker is always drawn. The default is "".
  • -hide boolean โ€” Indicates whether the marker is drawn. If boolean is true, the marker is not drawn. The default is no.
  • -mapx xAxis โ€” Specifies the X-axis to map the marker's X-coordinates onto. xAxis must be the name of an axis. The default is x.
  • -mapy yAxis โ€” Specifies the Y-axis to map the marker's Y-coordinates onto. yAxis must be the name of an axis. The default is y.
  • -name markerId โ€” Changes the identifier for the marker. The identifier markerId can not already be used by another marker. If this option isn't specified, the marker's name is uniquely generated.
  • -under boolean โ€” Indicates whether the marker is drawn below/above data elements. If boolean is true, the marker is drawn underneath the data elements. Otherwise, the marker is drawn on top of the element. The default is 0.
  • -xoffset pixels โ€” Specifies a screen distance to offset the marker horizontally. pixels is a valid screen distance, such as 2 or 1.2i. The default is 0.
  • -yoffset pixels โ€” Specifies a screen distance to offset the markers vertically. pixels is a valid screen distance, such as 2 or 1.2i. The default is 0.

Marker configuration options may also be set by the option command. The resource class is either BitmapMarker, ImageMarker, LineMarker, PolygonMarker, TextMarker, or WindowMarker, depending on the type of marker. The resource name is the name of the marker.

option add *Barchart.TextMarker.Foreground white
option add *Barchart.BitmapMarker.Foreground white
option add *Barchart.m1.Background     blue
pathName marker create type ?option value?...

Creates a marker of the selected type. type may be either text, line, bitmap, image, polygon, or window. This command returns the marker identifier, used as the markerId argument in the other marker-related commands. If the -name option is used, this overrides the normal marker identifier. If the name provided is already used for another marker, the new marker will replace the old.

pathName marker delete ?name?...

Removes one or more markers. The graph will automatically be redrawn without the marker..

pathName marker exists markerId

Returns 1 if the marker markerId exists and 0 otherwise.

pathName marker names ?pattern?

Returns the names of all the markers that currently exist. If pattern is supplied, only those markers whose names match it will be returned.

pathName marker type markerId

Returns the type of the marker given by markerId, such as line or text. If markerId is not a valid a marker identifier, "" is returned.


๐Ÿ–ผ๏ธ BITMAP MARKERS ๐Ÿ’–

A bitmap marker displays a bitmap. The size of the bitmap is controlled by the number of coordinates specified. If two coordinates, they specify the position of the top-left corner of the bitmap. The bitmap retains its normal width and height. If four coordinates, the first and second pairs of coordinates represent the corners of the bitmap. The bitmap will be stretched or reduced as necessary to fit into the bounding rectangle.

Bitmap markers are created with the marker's create operation in the form:

pathName marker create bitmap ?option value?...

There may be many option-value pairs, each sets a configuration option for the marker. These same option-value pairs may be used with the marker's configure operation.

The following options are specific to bitmap markers:

  • -background color โ€” Same as the -fill option.
  • -bitmap bitmap โ€” Specifies the bitmap to be displayed. If bitmap is "", the marker will not be displayed. The default is "".
  • -fill color โ€” Sets the background color of the bitmap. If color is the empty string, no background will be transparent. The default background color is "".
  • -foreground color โ€” Same as the -outline option.
  • -mask mask โ€” Specifies a mask for the bitmap to be displayed. This mask is a bitmap itself, denoting the pixels that are transparent. If mask is "", all pixels of the bitmap will be drawn. The default is "".
  • -outline color โ€” Sets the foreground color of the bitmap. The default value is black.
  • -rotate theta โ€” Sets the rotation of the bitmap. theta is a real number representing the angle of rotation in degrees. The marker is first rotated and then placed according to its anchor position. The default rotation is 0.0.

๐Ÿ–ผ๏ธ IMAGE MARKERS ๐Ÿฆ‹

An image marker displays an image. Image markers are created with the marker's create operation in the form:

pathName marker create image ?option value?...

There may be many option-value pairs, each sets a configuration option for the marker. These same option-value pairs may be used with the marker's configure operation.

The following options are specific to image markers:

  • -anchor anchor โ€” anchor tells how to position the image relative to the positioning point for the image. For example, if anchor is center then the image is centered on the point; if anchor is n then the image will be drawn such that the top center point of the rectangular region occupied by the image will be at the positioning point. This option defaults to center.
  • -image image โ€” Specifies the image to be drawn. If image is "", the marker will not be drawn. The default is "".

๐Ÿ“ LINE MARKERS โœจ

A line marker displays one or more connected line segments. Line markers are created with the marker's create operation in the form:

pathName marker create line ?option value?...

There may be many option-value pairs, each sets a configuration option for the marker. These same option-value pairs may be used with the marker's configure operation.

The following options are specific to line markers:

  • -dashes dashList โ€” Sets the dash style of the line. dashList is a list of up to 11 numbers that alternately represent the lengths of the dashes and gaps on the line. Each number must be between 1 and 255. If dashList is "", the marker line will be solid.
  • -fill color โ€” Sets the background color of the line. This color is used with striped lines (see the -fdashes option). If color is the empty string, no background color is drawn (the line will be dashed, not striped). The default background color is "".
  • -linewidth pixels โ€” Sets the width of the lines. The default width is 0.
  • -outline color โ€” Sets the foreground color of the line. The default value is black.
  • -stipple bitmap โ€” Specifies a stipple pattern used to draw the line, rather than a solid line. bitmap specifies a bitmap to use as the stipple pattern. If bitmap is "", then the line is drawn in a solid fashion. The default is "".

๐Ÿ”ท POLYGON MARKERS ๐Ÿ‘‘

A polygon marker displays a closed region described as two or more connected line segments. It is assumed the first and last points are connected. Polygon markers are created using the marker create operation in the form:

pathName marker create polygon ?option value?...

There may be many option-value pairs, each sets a configuration option for the marker. These same option-value pairs may be used with the marker configure command to change the marker's configuration.

The following options are supported for polygon markers:

  • -dashes dashList โ€” Sets the dash style of the outline of the polygon. dashList is a list of up to 11 numbers that alternately represent the lengths of the dashes and gaps on the outline. Each number must be between 1 and 255. If dashList is "", the outline will be a solid line.
  • -fill color โ€” Sets the fill color of the polygon. If color is "", then the interior of the polygon is transparent. The default is white.
  • -linewidth pixels โ€” Sets the width of the outline of the polygon. If pixels is zero, no outline is drawn. The default is 0.
  • -outline color โ€” Sets the color of the outline of the polygon. If the polygon is stippled (see the -stipple option), then this represents the foreground color of the stipple. The default is black.
  • -stipple bitmap โ€” Specifies that the polygon should be drawn with a stippled pattern rather than a solid color. bitmap specifies a bitmap to use as the stipple pattern. If bitmap is "", then the polygon is filled with a solid color (if the -fill option is set). The default is "".

โœจ TEXT MARKERS โœจ

A text marker is literally just a string of characters chillinโ€™ on one or more lines of text. Embedded newlines cause line breaks, bestie โ€” and these cuties are perfect for annotating regions of the graph. You create one with the create operation, like this:

pathName marker create text ?option value?...

There may be many option-value pairs, and each one sets a configuration option for the text marker. Those same option-value pairs can also be used with the markerโ€™s configure operation. Slay.

The following options are specific to text markers:

  • -anchor anchor โ€” Tells how to position the text relative to the positioning point for the text. For example, if anchor is center then the text is centered on the point; if anchor is n then the text will be drawn such that the top center point of the rectangular region occupied by the text will be at the positioning point. This default is center.
  • -background color โ€” Same as the -fill option.
  • -font fontName โ€” Specifies the font of the text. The default is *-Helvetica-Bold-R-Normal-*-120-*.
  • -fill color โ€” Sets the background color of the text. If color is the empty string, no background will be transparent. The default background color is "".
  • -foreground color โ€” Same as the -outline option.
  • -justify justify โ€” Specifies how the text should be justified. This matters only when the marker contains more than one line of text. Justify must be left, right, or center. The default is center.
  • -outline color โ€” Sets the color of the text. The default value is black.
  • -padx pad โ€” Sets the padding to the left and right exteriors of the text. Pad can be a list of one or two screen distances. If pad has two elements, the left side of the text is padded by the first distance and the right side by the second. If pad has just one distance, both the left and right sides are padded evenly. The default is 4.
  • -pady pad โ€” Sets the padding above and below the text. Pad can be a list of one or two screen distances. If pad has two elements, the area above the text is padded by the first distance and the area below by the second. If pad is just one distance, both the top and bottom areas are padded evenly. The default is 4.
  • -rotate theta โ€” Specifies the number of degrees to rotate the text. Theta is a real number representing the angle of rotation. The marker is first rotated along its center and is then drawn according to its anchor position. The default is 0.0.
  • -text text โ€” Specifies the text of the marker. The exact way the text is displayed may be affected by other options such as -anchor or -rotate.

๐ŸชŸ WINDOW MARKERS ๐ŸชŸ

A window marker displays a widget at a given position. Window markers are created with the markerโ€™s create operation in the form:

pathName marker create window ?option value?...

There may be many option-value pairs, each one setting a configuration option for the marker. These same option-value pairs may be used with the markerโ€™s configure command. Periodt.

The following options are specific to window markers:

  • -anchor anchor โ€” Tells how to position the widget relative to the positioning point for the widget. For example, if anchor is center then the widget is centered on the point; if anchor is n then the widget will be displayed such that the top center point of the rectangular region occupied by the widget will be at the positioning point. This option defaults to center.
  • -height pixels โ€” Specifies the height to assign to the markerโ€™s window. If this option isnโ€™t specified, or if it is specified as "", then the window is given whatever height the widget requests internally.
  • -width pixels โ€” Specifies the width to assign to the markerโ€™s window. If this option isnโ€™t specified, or if it is specified as "", then the window is given whatever width the widget requests internally.
  • -window pathName โ€” Specifies the widget to be managed by the barchart. PathName must be a child of the barchart widget.

๐Ÿ”— GRAPH COMPONENT BINDINGS ๐Ÿ”—

Specific barchart components โ€” like elements, markers, and legend entries โ€” can have a command trigger when an event occurs in them, much like canvas items in Tkโ€™s canvas widget. Not all event sequences are valid, bestie. The only binding events that may be specified are those related to the mouse and keyboard (such as Enter, Leave, ButtonPress, Motion, and KeyPress).

Only one element or marker can be picked during an event. This means that if the mouse is directly over both an element and a marker, only the uppermost component is selected. This isnโ€™t true for legend entries. Both a legend entry and an element (or marker) binding commands will be invoked if both items are picked.

It is possible for multiple bindings to match a particular event. This could occur, for example, if one binding is associated with the element name and another is associated with one of the elementโ€™s tags (see the -bindtags option). When this occurs, all of the matching bindings are invoked. A binding associated with the element name is invoked first, followed by one binding for each of the elementโ€™s bindtags. If there are multiple matching bindings for a single tag, then only the most specific binding is invoked. A continue command in a binding script terminates that script, and a break command terminates that script and skips any remaining scripts for the event, just as for the bind command.

The -bindtags option for these components controls addition tag names which can be matched. Implicitly elements and markers always have tags matching their names. Setting the value of the -bindtags option doesnโ€™t change this.


๐Ÿ’ป C LANGUAGE API ๐Ÿ’ป

You can manipulate data elements from the C language. There may be situations where it is too expensive to translate the data values from ASCII strings. Or you might want to read data in a special file format. Iconic.

Data can manipulated from the C language using BLT vectors. You specify the X-Y data coordinates of an element as vectors and manipulate the vector from C. The barchart will be redrawn automatically after the vectors are updated.

From Tcl, create the vectors and configure the element to use them.

vector X Y
.g element configure line1 -xdata X -ydata Y

To set data points from C, you pass the values as arrays of doubles using the Blt_ResetVector call. The vector is reset with the new data and at the next idle point (when Tk re-enters its event loop), the graph will be redrawn automatically.

#include <tcl.h>
#include <blt.h>

register int i;
Blt_Vector *xVec, *yVec;
double x[50], y[50];

/* Get the BLT vectors "X" and "Y" (created above from Tcl) */
if ((Blt_GetVector(interp, "X", 50, &xVec) != TCL_OK) ||
    (Blt_GetVector(interp, "Y", 50, &yVec) != TCL_OK)) {
    return TCL_ERROR;
}

for (i = 0; i < 50; i++) {
    x[i] = i * 0.02;
    y[i] = sin(x[i]);
}

/* Put the data into BLT vectors */
if ((Blt_ResetVector(xVec, x, 50, 50, TCL_VOLATILE) != TCL_OK) ||
    (Blt_ResetVector(yVec, y, 50, 50, TCL_VOLATILE) != TCL_OK)) {
   return TCL_ERROR;
}

See the vector manual page for more details.


โšก SPEED TIPS โšก

There may be cases where the bar chart needs to be drawn and updated as quickly as possible. If drawing speed becomes a big problem, here are a few tips to speed up displays. Bestie, take notes.

  • Try to minimize the number of data points. The more data points looked at, the more work the bar chart must do.
  • If your data is generated as floating point values, the time required to convert the data values to and from ASCII strings can be significant, especially when there any many data points. You can avoid the redundant string-to-decimal conversions using the C API to BLT vectors.
  • Donโ€™t stipple or dash the element. Solid bars are much faster.
  • If you update data elements frequently, try turning off the widgetโ€™s -bufferelements option. When the bar chart is first displayed, it draws data elements into an internal pixmap. The pixmap acts as a cache, so that when the bar chart needs to be redrawn again, and the data elements or coordinate axes havenโ€™t changed, the pixmap is simply copied to the screen. This is especially useful when you are using markers to highlight points and regions on the bar chart. But if the bar chart is updated frequently, changing either the element data or coordinate axes, the buffering becomes redundant.

๐Ÿšง LIMITATIONS ๐Ÿšง

Auto-scale routines do not use requested min/max limits as boundaries when the axis is logarithmically scaled.

The PostScript output generated for polygons with more than 1500 points may exceed the limits of some printers (See PostScript Language Reference Manual, page 568). The work-around is to break the polygon into separate pieces.


๐Ÿท๏ธ KEYWORDS ๐Ÿท๏ธ

bar chart, widget


Thatโ€™s the whole page, bestie! Footer vibes: BLT 2.5 / barchart(n). You ate. ๐Ÿ’…โœจ๐Ÿ’–

๐Ÿ“ฆ where this page comes from
  • nixpkgs unstable: blt 2.5.3
  • ๐Ÿ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms