File tree Expand file tree Collapse file tree
packages/layerchart/src/routes/docs/components/BarChart Expand file tree Collapse file tree Original file line number Diff line number Diff line change 589589 </div >
590590</Preview >
591591
592+ <h2 >Group series (labels)</h2 >
593+
594+ <Preview data ={wideData }>
595+ <div class =" h-[300px] p-4 border rounded-sm" >
596+ <BarChart
597+ data ={wideData }
598+ x =" year"
599+ series ={[
600+ { key: ' apples' , color: ' var(--color-danger)' },
601+ {
602+ key: ' bananas' ,
603+ color: ' var(--color-warning)' ,
604+ },
605+ {
606+ key: ' cherries' ,
607+ color: ' var(--color-success)' ,
608+ },
609+ {
610+ key: ' grapes' ,
611+ color: ' var(--color-info)' ,
612+ },
613+ ]}
614+ seriesLayout =" group"
615+ props ={{
616+ xAxis : { format : ' none' },
617+ yAxis : { format : ' metric' },
618+ tooltip : {
619+ header : { format : ' none' },
620+ },
621+ }}
622+ {renderContext }
623+ {debug }
624+ >
625+ <!-- Workaround until x1Scale is directly handled by Points/Labels: https://github.com/techniq/layerchart/issues/473#issuecomment-3266370636 -->
626+ {#snippet aboveMarks ({ context , visibleSeries })}
627+ {#each visibleSeries as s }
628+ {#each wideData as d }
629+ {@const valueAccessor = accessor (s .key )}
630+ {@const value = valueAccessor (d )}
631+ <Text
632+ x ={context .xScale (d .year ) +
633+ (context .x1Scale ?.(s .key ) ?? 0 ) +
634+ (context .x1Scale ?.bandwidth ?.() ?? 0 ) / 2 }
635+ y ={context .yScale (value )}
636+ {value }
637+ textAnchor =" middle"
638+ class =" text-xs"
639+ />
640+ {/each }
641+ {/each }
642+ {/ snippet }
643+ </BarChart >
644+ </div >
645+ </Preview >
646+
592647<h2 >Group series (horizontal)</h2 >
593648
594649<Preview data ={wideData }>
You can’t perform that action at this time.
0 commit comments