Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Website | Gallery: Update Basic Grouped Bar Chart Legend #371

Merged
merged 1 commit into from
Apr 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading