Documentation

Report Edit

NonOverlappingRect

import { NonOverlappingRect, NonOverlappingRectGroup } from 'cx/svg';

The NonOverlappingRect and NonOverlappingRectGroup widgets are commonly used for hiding excessive chart labels. In the following chart, labels which are overlapping other labels are hidden. Try dragging markers around and see how it behaves.

100150200250300350400050100150200250300183, 235114, 196262, 79280, 21152, 15195, 130290, 126274, 4227, 274259, 61196, 185307, 168351, 130142, 220315, 274193, 154312, 103143, 140203, 6346, 155107, 36381, 66347, 233208, 48262, 214
<div class="widgets" controller={PageController}>
    <Svg style="width:500px; height:450px;">
        <Chart
            offset="50 -20 -40 130"
            axes={{
                x: { type: NumericAxis, snapToTicks: 1 },
                y: { type: NumericAxis, vertical: true, snapToTicks: 1 }
            }}
        >
            <NonOverlappingRectGroup>
                <Gridlines />
                <Repeater records-bind="$page.data" recordName="$point">
                    <Marker
                        colorIndex={0}
                        size={10}
                        x-bind="$point.x"
                        y-bind="$point.y"
                        style={{ fillOpacity: 0.5 }}
                        draggableX
                        draggableY
                    >
                        <NonOverlappingRect offset="-15 25 0 -25" anchors="0 0.5 0 0.5">
                            <Rectangle style="fill: white; stroke: red; stroke-width: 0.5" anchors="0 1 1 0" rx="3">
                                <Text value-tpl="{$point.x:n;0}, {$point.y:n;0}" textAnchor="middle" style="font-size: 10px" dy="0.35em" />
                            </Rectangle>
                        </NonOverlappingRect>
                    </Marker>
                </Repeater>
            </NonOverlappingRectGroup>
        </Chart>
    </Svg>
</div>
Copied!Cx Fiddle
PropertyDescriptionType
anchors

Anchor defines how child bounds are tied to the parent. Zero aligns with the top/left edge. One aligns with the bottom/right edge. See Svg for more information.

string/number/rect
class
className

Additional CSS classes to be applied to the element. If an object is provided, all keys with a "truthy" value will be added to the CSS class list.

string/object
items
children

List of child elements.

array
margin

Apply margin to the given boundaries. See Svg for more information.

string/number/rect
mod

Appearance modifier. For example, mod="big" will add the CSS class .cxm-big to the block element.

string/array
offset

Move boundaries specified by the offset. See Svg for more information.

string/number/rect
outerLayout

Defines the outer layout which wraps the widget.

widget
padding

Padding to be applied to the boundaries rectangle before passing to the children.

string/number/rect
plainText

Set to true to avoid converting inner strings to templates. Default is false.

boolean
preserveWhitespace
ws

Keep whitespace in text based children. Default is false. See also trimWhitespace.

boolean
putInto
contentFor

Used with outer layouts. Specifies the name of the content placeholder which should render the widget.

string
style

Style object applied to the wrapper div. Used for setting the dimensions of the element.

string/object
trimWhitespace

Remove all whitespace in text based children. Default is true. See also preserveWhitespace.

boolean
vdomKey

Key that will be used as the key when rendering the React component.

string
visible
if

Visibility of the widget. Defaults to true.

boolean