Skip to content

Graphics

Components for rendering graphical elements such as shapes, ribbons and color scales.

KShape

Renders an SVG shape using the @kalisio/common-graphics library. Supported shape types include circle, rect, diamond, triangle, star5, hexagon, and more.

Props

PropTypeDefaultDescription
optionsObject(required)Shape descriptor passed to Graphiks.renderShape(). Must include at least a shape key with a registered shape type name.
tooltipStringundefinedText displayed in a Quasar tooltip on hover.

Usage

html
<!-- Basic circle -->
<KShape :options="{ shape: 'circle', size: 32 }" />

<!-- Triangle with a custom color -->
<KShape :options="{ shape: 'triangle', size: 24, color: '#e53935' }" />

<!-- With a tooltip -->
<KShape :options="{ shape: 'star5', size: 28 }" tooltip="Favorite" />

KRibbon

Renders a diagonal banner ribbon, typically used to overlay a corner of a card or panel (e.g. "Beta", "New").

Props

PropTypeDefaultDescription
textStringundefinedText displayed inside the ribbon.
sizeNumber32Height of the ribbon in pixels. Font size is derived as size - 8.
colorString'primary'Background color. Accepts any Quasar palette name, HTML color name, or CSS color value.
textColorString'white'Text color. Same accepted formats as color.
letterSpacingNumber2Letter spacing in pixels.
positionString'top-left'Corner where the ribbon is anchored. One of top-left, top-right, bottom-right, bottom-left.
originArray[50, 50][x, y] offset in pixels from the chosen corner, used to fine-tune positioning.

Usage

html
<!-- Top-left "Beta" ribbon -->
<KRibbon text="Beta" />

<!-- Bottom-right ribbon with a custom color -->
<KRibbon text="New" position="bottom-right" color="#43a047" :origin="[60, 60]" />

<!-- Larger ribbon with adjusted letter spacing -->
<KRibbon text="Alpha" :size="40" :letterSpacing="4" color="deep-orange" />

KColorScale

Renders a continuous or discrete color scale on an HTML canvas. The scale automatically redraws when its container is resized.

Props

PropTypeDefaultDescription
labelStringundefinedTitle displayed above the color bar.
colorsString | Array'OrRd'Color scheme. Accepts a Chroma.js scale name (e.g. 'OrRd', 'Viridis') or an array of CSS color values.
domainArray[0, 1]Value range [min, max]. Use a reversed array (e.g. [1, 0]) to reverse the scale direction.
classesArraynullClass boundaries for a discrete scale. When set, the scale renders one colored box per interval. When null, the scale is continuous.
unitStringundefinedUnit identifier. Reserved for future use.
layoutObjectsee belowLayout configuration object.
directionString'horizontal'Orientation of the scale. One of horizontal, vertical.

layout object

KeyTypeDefaultDescription
gutterNumber4Spacing in pixels between the label, the color bar and the ticks.
label.sizeNumber12Label font size in pixels.
label.fontString'Arial'Label font family.
label.colorString'black'Label text color.
label.alignString'left'Label text alignment. One of left, center, right.
bar.heightNumber16Color bar height in pixels (horizontal mode).
bar.widthNumber16Color bar width in pixels (vertical mode).
ticks.sizeNumber10Tick label font size in pixels.
ticks.fontString'Arial'Tick label font family.
ticks.colorString'black'Tick label text color.
ticks.formatObject | Function{ notation: 'auto', precision: 3 }Tick formatting. Accepts a mathjs format options object or a function ({ tick, previousTick }) => string. Returning a falsy value hides the tick.

Usage

Continuous horizontal scale

KColorScale continuous horizontal

html
<KColorScale label="Temperature" colors="RdYlBu" :domain="[-20, 40]" />

Discrete horizontal scale

KColorScale discrete horizontal

html
<KColorScale
  label="Elevation"
  colors="OrRd"
  :domain="[0, 3000]"
  :classes="[0, 500, 1000, 2000, 3000]"
/>

Continuous vertical scale

html
<KColorScale
  label="Wind speed"
  colors="Viridis"
  :domain="[0, 30]"
  direction="vertical"
/>

Reversed domain

html
<KColorScale colors="Blues" :domain="[100, 0]" />

Custom tick formatting

html
<KColorScale
  :domain="[0, 1]"
  :layout="{
    ticks: {
      format: ({ tick }) => `${(tick * 100).toFixed(0)} %`
    }
  }"
/>