Skip to content

Commit

Permalink
Website | Gallery: Update Basic Grouped Bar Chart Legend
Browse files Browse the repository at this point in the history
  • Loading branch information
lee00678 committed Apr 25, 2024
1 parent 4550e91 commit 0999a98
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Component } from '@angular/core'
import { data, colors, ElectionDatum } from './data'
import { data, colors, capitalize, ElectionDatum } from './data'

@Component({
selector: 'basic-grouped-bar',
Expand All @@ -17,7 +17,7 @@ export class BasicGroupedBarComponent {
data = data

legendItems = Object.entries(colors).map(([n, c]) => ({
name: n.toUpperCase(),
name: capitalize(n),
color: c,
}))

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<script lang='ts'>
import { VisXYContainer, VisGroupedBar, VisAxis, VisBulletLegend } from '@unovis/svelte'
import { data, colors, ElectionDatum } from './data'
import { data, colors, capitalize, ElectionDatum } from './data'
const items = Object.entries(colors).map(([n, c]) => ({
name: n.toUpperCase(),
name: capitalize(n),
color: c,
}))
const x = (d: ElectionDatum) => d.year
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { XYContainer, Axis, GroupedBar, BulletLegend } from '@unovis/ts'
import { data, colors, ElectionDatum } from './data'
import { data, colors, capitalize, ElectionDatum } from './data'

const container = document.getElementById('vis-container')

const legendItems = Object.entries(colors).map(([n, c]) => ({
name: n.toUpperCase(),
name: capitalize(n),
color: c,
}))
const legend = new BulletLegend(container, { items: legendItems })
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import React, { useCallback } from 'react'
import { VisXYContainer, VisGroupedBar, VisAxis, VisBulletLegend } from '@unovis/react'

import { data, colors } from './data'
import { data, capitalize, colors } from './data'

const legendItems = Object.entries(colors).map(([n, c]) => ({
name: n.toUpperCase(),
name: capitalize(n),
color: c,
}))

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<script setup lang="ts">
import { VisXYContainer, VisGroupedBar, VisAxis, VisBulletLegend } from '@unovis/vue'
import { data, colors, ElectionDatum } from './data'
import { data, capitalize, colors, ElectionDatum } from './data'
const items = Object.entries(colors).map(([n, c]) => ({
name: n.toUpperCase(),
name: capitalize(n),
color: c,
}))
const x = (d: ElectionDatum) => d.year
Expand Down
4 changes: 4 additions & 0 deletions packages/shared/examples/basic-grouped-bar/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ export const colors = {
libertarian: '#34daa6',
}

export const capitalize = (s: string): string => {
return s.charAt(0).toUpperCase() + s.slice(1)
}

export const data: ElectionDatum[] = [
{
year: 1980,
Expand Down

0 comments on commit 0999a98

Please sign in to comment.