Documentation

Report Edit

Bar Chart Example

This example shows how to connect grid and chart. Sorting and selection in the grid is applied to the chart too.

New AdelineKareemfurtEast SkylaNew AniyaEast TavarestonNorth AracelytonNew FurmanchesterAmiramouthStreichchesterWest CynthiaviewWest ChristianaCleveton050100150200250300
City
V1
V2
V3
New Adeline95.02151.03205.68
Kareemfurt105.93233.51169.48
East Skyla101.24185.90165.84
New Aniya89.15184.40172.15
East Tavareston83.29199.29155.99
North Aracelyton87.21155.33145.61
New Furmanchester97.42206.36242.14
Amiramouth98.65190.00227.24
Streichchester98.67238.83166.20
West Cynthiaview97.69235.41237.33
West Christiana90.95222.08207.07
Cleveton103.75250.47188.27
var legendStyle = "border-width:1px;border-style:solid;display:inline-block;width:20px;height:10px;";
<Svg style="width:600px; height:600px;">
   <Chart offset="20 -20 -40 150" axes={{ y: { type: CategoryAxis, vertical: true, inverted: true }, x: { type: NumericAxis, snapToTicks: 1 } }}>
      <Gridlines/>
      <Repeater records-bind="$page.points" recordAlias="$point" sorters-bind="$page.sorters">
         <Bar colorIndex={0}
              height={0.2}
              offset={-0.2}
              x-bind="$point.v1"
              y-bind="$point.city"
              selection={barSelection}
              tooltip-tpl="{$point.v1:n;0}" />

         <Bar colorIndex={2}
              height={0.2}
              offset={0}
              x-bind="$point.v2"
              y-bind="$point.city"
              selection={barSelection}
              tooltip-tpl="{$point.v2:n;0}" />

         <Bar colorIndex={4}
              height={0.2}
              offset={0.2}
              x-bind="$point.v3"
              y-bind="$point.city"
              selection={barSelection}
              tooltip-tpl="{$point.v3:n;0}" />
      </Repeater>
   </Chart>
</Svg>
<Grid records-bind="$page.points"
      sorters-bind="$page.sorters"
      columns={[
         { header: 'City', field: 'city', sortable: true },
         { field: 'v1', format: 'n;2', align: "right", sortable: true,
            header: {
               items: <cx>
                  <div preserveWhitespace>
                     V1
                     <div class="cxs-color-0" style={legendStyle}></div>
                  </div>
               </cx>
            }
         },
         { field: 'v2', format: 'n;2', align: "right", sortable: true,
            header: {
               items: <cx>
                  <div preserveWhitespace>
                      V2
                      <div class="cxs-color-2" style={legendStyle}></div>
                  </div>
               </cx>
            }
         },
         { field: 'v3', format: 'n;2', align: "right", sortable: true,
            header: {
            items: <cx>
               <div preserveWhitespace>
                   V3
                   <div class="cxs-color-4" style={legendStyle}></div>
               </div>
            </cx>
            }
         }
      ]}
      selection={{type: PropertySelection, keyField: 'id', bind: '$page.selection' }}/>
Copied!Cx Fiddle