-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Website | Gallery: Basic Donut Chart
- Loading branch information
Showing
14 changed files
with
179 additions
and
1 deletion.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions
12
packages/shared/examples/basic-donut-chart/basic-donut-chart.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
|
||
<h3>Most Common Password Categories</h3> | ||
<vis-bullet-legend [items]="legendItems"></vis-bullet-legend> | ||
<vis-single-container [height]="400"> | ||
<vis-donut | ||
[value]="value" | ||
[data]="data" | ||
[showEmptySegments]="true" | ||
[padAngle]="0.01" | ||
[arcWidth]="100" | ||
/> | ||
</vis-single-container> |
16 changes: 16 additions & 0 deletions
16
packages/shared/examples/basic-donut-chart/basic-donut-chart.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { Component } from '@angular/core' | ||
import { data, DataRecord } from './data' | ||
|
||
@Component({ | ||
selector: 'basic-donut-chart-component', | ||
templateUrl: './basic-donut-chart.component.html', | ||
}) | ||
|
||
export class BasicDonutChartComponent { | ||
value = (d: DataRecord): number => d.value | ||
data = data | ||
legendItems = Object.entries(data).map(([_, data]) => ({ | ||
name: data.key.charAt(0).toUpperCase() + data.key.slice(1), | ||
})) | ||
} | ||
|
11 changes: 11 additions & 0 deletions
11
packages/shared/examples/basic-donut-chart/basic-donut-chart.module.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { NgModule } from '@angular/core' | ||
import { VisSingleContainerModule, VisDonutModule, VisBulletLegendModule } from '@unovis/angular' | ||
|
||
import { BasicDonutChartComponent } from './basic-donut-chart.component' | ||
|
||
@NgModule({ | ||
imports: [VisSingleContainerModule, VisDonutModule, VisBulletLegendModule], | ||
declarations: [BasicDonutChartComponent], | ||
exports: [BasicDonutChartComponent], | ||
}) | ||
export class BasicDonutChartModule { } |
21 changes: 21 additions & 0 deletions
21
packages/shared/examples/basic-donut-chart/basic-donut-chart.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<script lang='ts'> | ||
import { VisSingleContainer, VisDonut, VisBulletLegend } from '@unovis/svelte' | ||
import { data, DataRecord } from './data' | ||
const legendItems = Object.entries(data).map(([_, data]) => ({ | ||
name: data.key.charAt(0).toUpperCase() + data.key.slice(1), | ||
})) | ||
</script> | ||
|
||
<h3>Most Common Password Categories</h3> | ||
<VisBulletLegend items={legendItems}/> | ||
<VisSingleContainer height={400}> | ||
<VisDonut | ||
value={d => d.value} | ||
{data} | ||
showEmptySegments={true} | ||
padAngle={0.01} | ||
arcWidth={100} | ||
/> | ||
</VisSingleContainer> | ||
|
21 changes: 21 additions & 0 deletions
21
packages/shared/examples/basic-donut-chart/basic-donut-chart.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { Donut, SingleContainer, BulletLegend } from '@unovis/ts' | ||
import { data, DataRecord } from './data' | ||
|
||
const container = document.getElementById('vis-container') | ||
container.innerHTML = '<h3>Most Common Password Categories</h3>' | ||
|
||
const legendItems = Object.entries(data).map(([_, data]) => ({ | ||
name: data.key.charAt(0).toUpperCase() + data.key.slice(1), | ||
})) | ||
const legend = new BulletLegend(container, { items: legendItems }) | ||
|
||
const chart = new SingleContainer(container, { | ||
component: new Donut<DataRecord>({ | ||
value: (d: DataRecord) => d.value, | ||
showEmptySegments: true, | ||
padAngle: 0.01, | ||
arcWidth: 100, | ||
}), | ||
height: 400, | ||
}, data) | ||
|
26 changes: 26 additions & 0 deletions
26
packages/shared/examples/basic-donut-chart/basic-donut-chart.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import React, { useCallback } from 'react' | ||
import { VisSingleContainer, VisDonut, VisBulletLegend } from '@unovis/react' | ||
|
||
import { data } from './data' | ||
|
||
const legendItems = Object.entries(data).map(([_, data]) => ({ | ||
name: data.key.charAt(0).toUpperCase() + data.key.slice(1), | ||
})) | ||
|
||
export default function BasicDonutChart (): JSX.Element { | ||
return ( | ||
<> | ||
<h3>Most Common Password Categories</h3> | ||
<VisBulletLegend items={legendItems}/> | ||
<VisSingleContainer height={400}> | ||
<VisDonut | ||
value={useCallback(d => d.value, [])} | ||
data={data} | ||
showEmptySegments={true} | ||
padAngle={0.01} | ||
arcWidth={100} | ||
/> | ||
</VisSingleContainer> | ||
</> | ||
) | ||
} |
23 changes: 23 additions & 0 deletions
23
packages/shared/examples/basic-donut-chart/basic-donut-chart.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<script setup lang="ts"> | ||
import { VisSingleContainer, VisDonut, VisBulletLegend } from '@unovis/vue' | ||
import { data, DataRecord } from './data' | ||
const legendItems = Object.entries(data).map(([_, data]) => ({ | ||
name: data.key.charAt(0).toUpperCase() + data.key.slice(1) | ||
})) | ||
</script> | ||
|
||
<template> | ||
<h3>Most Common Password Categories</h3> | ||
<VisBulletLegend :items="legendItems"/> | ||
<VisSingleContainer :height="400"> | ||
<VisDonut | ||
:value="d => d.value" | ||
:data="data" | ||
:showEmptySegments="true" | ||
:padAngle="0.01" | ||
:arcWidth="100" | ||
/> | ||
</VisSingleContainer> | ||
</template> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
export type DataRecord = { key: string; value: number } | ||
|
||
export const data: DataRecord[] = [ | ||
{ key: 'names', value: 1396 }, | ||
{ key: 'cool', value: 928 }, | ||
{ key: 'alphanumeric', value: 864 }, | ||
{ key: 'fluffy', value: 518 }, | ||
{ key: 'nerdy', value: 294 }, | ||
{ key: 'other', value: 916 }, | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* eslint-disable import/no-unresolved, import/no-webpack-loader-syntax, @typescript-eslint/no-var-requires */ | ||
import React from 'react' | ||
import type { Example } from '../types' | ||
|
||
const pathname = 'basic-donut-chart' | ||
const example: Example = { | ||
component: () => { | ||
// eslint-disable-next-line @typescript-eslint/naming-convention | ||
const Component = require(`./${pathname}.tsx`).default | ||
return <Component /> | ||
}, | ||
pathname, | ||
title: 'Basic Donut Chart', | ||
description: <div>Data obtained from <a href="https://informationisbeautiful.net/visualizations/top-500-passwords-visualized/" target="_blank">information is beautiful</a></div>, | ||
codeReact: require(`!!raw-loader!./${pathname}.tsx`).default, | ||
codeTs: require(`!!raw-loader!./${pathname}.ts`).default, | ||
codeAngular: { | ||
html: require(`!!raw-loader!./${pathname}.component.html`).default, | ||
component: require(`!!raw-loader!./${pathname}.component.ts`).default, | ||
module: require(`!!raw-loader!./${pathname}.module.ts`).default, | ||
}, | ||
codeSvelte: require(`!!raw-loader!./${pathname}.svelte`).default, | ||
codeVue: require(`!!raw-loader!./${pathname}.vue`).default, | ||
data: require('!!raw-loader!./data').default, | ||
preview: require(`../_previews/${pathname}.png`).default, | ||
previewDark: require(`../_previews/${pathname}-dark.png`).default, | ||
} | ||
|
||
export default example |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters