Skip to content

Commit 11495d3

Browse files
Update How to Create a Chart docs
1 parent f8ff174 commit 11495d3

2 files changed

Lines changed: 35 additions & 40 deletions

File tree

src/storybook/stories/using-respvis/charts/how-to-create-a-chart/how-to-create-a-chart-advanced.mdx

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,6 @@ in figuring out which arguments are required:
127127

128128
<Source code={`
129129
import { LineChart, LineChartUserArgs, formatWithDecimalZero, select, format, timeFormat, timeYear } from 'respvis';
130-
import {select, format, timeFormat, timeYear} from "d3";
131130
132131
// Data Source: Studierendenstatistik
133132
// https://online.tugraz.at/tug_online/studierendenstatistik.html
@@ -340,7 +339,7 @@ In addition, one can decide to move information from the title to the smaller su
340339
...
341340
const args: LineChartUserArgs = {
342341
...
343-
breakPoints: {
342+
breakpoints: {
344343
width: {
345344
values: [20, 30, 50],
346345
unit: 'rem'
@@ -375,7 +374,7 @@ const args: LineChartUserArgs = {
375374
...
376375
x: {
377376
// Breakpoints can also be added to axes
378-
breakPoints: {
377+
breakpoints: {
379378
width: {
380379
values: [10, 30, 50],
381380
unit: 'rem'
@@ -403,14 +402,14 @@ const args: LineChartUserArgs = {
403402
},
404403
// By using breakpoints and tickOrientation one
405404
// can adjust the orientation depending on the
406-
// current layout width. The current mapping
405+
// current layout width. The current breakpointValues
407406
// can be read as: Ticks have 90° orientation
408-
// in layout width 0, 0° orientation in layout
409-
// width 3 and in between these widths the
410-
// tick orientation is interpolated.
407+
// if breakpoint 0 is undercut, 0° orientation if
408+
// breakpoint 2 is exceeded and in between these breakpoints
409+
// the tick orientation is interpolated.
411410
tickOrientation: {
412411
dependentOn: 'width',
413-
mapping: { 0: 90, 3: 0}
412+
breakpointValues: { 0: 90, 2: 0}
414413
}
415414
},
416415
y: {
@@ -451,10 +450,8 @@ const userArgs: LineChartUserArgs = {
451450
...
452451
series: {
453452
...
454-
markerTooltips: {
455-
tooltips: function (_, {xValue, yValue}) {
456-
return \`Year: \${xValue}<br/>Students: \${format('.2f')(yValue)}\`
457-
},
453+
markerTooltipGenerator: function (_, {xValue, yValue}) {
454+
return \`Year: \${xValue}<br/>Students: \${format('.2f')(yValue)}\`
458455
},
459456
labels: {
460457
values: students.map(student => student.toString()),

src/storybook/stories/using-respvis/charts/how-to-create-a-chart/how-to-create-a-chart-basic.mdx

Lines changed: 26 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ For the above markup to function properly it is necessary to
9292
implement `line-chart.js`:
9393

9494
<Source code={`
95-
import { LineChart, formatWithDecimalZero, select, format, timeFormat, timeYear } from 'respvis';
95+
import { LineChart, formatWithDecimalZero, select, format, timeFormat, timeYear } from './package/respvis.js';
9696
9797
// Data Source: Studierendenstatistik
9898
// https://online.tugraz.at/tug_online/studierendenstatistik.html
@@ -101,30 +101,30 @@ import { LineChart, formatWithDecimalZero, select, format, timeFormat, timeYear
101101
// ordentlich gemeldet, ohne Mitbeleger, jeweils im WS
102102
103103
const students = [
104-
8291, 8785, 9203, 9766, 10245, 11211, 11681, 12105, 12323,
105-
12565, 12764, 13167, 13454, 13737, 13373, 13566, 13673, 13712
104+
8291, 8785, 9203, 9766, 10245, 11211, 11681, 12105, 12323,
105+
12565, 12764, 13167, 13454, 13737, 13373, 13566, 13673, 13712
106106
]
107107
108108
const years = [
109-
"2004", "2005", "2006", "2007", "2008", "2009", "2010", "2011", "2012",
110-
"2013", "2014", "2015", "2016", "2017", "2018", "2019", "2020", "2021"
109+
"2004", "2005", "2006", "2007", "2008", "2009", "2010", "2011", "2012",
110+
"2013", "2014", "2015", "2016", "2017", "2018", "2019", "2020", "2021"
111111
]
112112
113113
export function createLineChart(selector) {
114-
const args = {
115-
series: {
116-
x: {
117-
values: years
118-
},
119-
y: {
120-
values: students
121-
}
114+
const args = {
115+
series: {
116+
x: {
117+
values: years
118+
},
119+
y: {
120+
values: students
121+
}
122+
}
122123
}
123-
}
124124
125-
const chartWindow = select(selector).append('div')
126-
const chart = new LineChart(chartWindow, args)
127-
chart.buildChart()
125+
const chartWindow = select(selector).append('div')
126+
const chart = new LineChart(chartWindow, args)
127+
chart.buildChart()
128128
}
129129
`} language={"typescript"}/>
130130

@@ -304,7 +304,7 @@ In addition, one can decide to move information from the title to the smaller su
304304
...
305305
const args = {
306306
...
307-
breakPoints: {
307+
breakpoints: {
308308
width: {
309309
values: [20, 30, 50],
310310
unit: 'rem'
@@ -339,7 +339,7 @@ const args = {
339339
...
340340
x: {
341341
// Breakpoints can also be added to axes
342-
breakPoints: {
342+
breakpoints: {
343343
width: {
344344
values: [10, 30, 50],
345345
unit: 'rem'
@@ -367,14 +367,14 @@ const args = {
367367
},
368368
// By using breakpoints and tickOrientation one
369369
// can adjust the orientation depending on the
370-
// current layout width. The current mapping
370+
// current layout width. The current breakpointValues
371371
// can be read as: Ticks have 90° orientation
372-
// in layout width 0, 0° orientation in layout
373-
// width 3 and in between these widths the
374-
// tick orientation is interpolated.
372+
// if breakpoint 0 is undercut, 0° orientation if
373+
// breakpoint 2 is exceeded and in between these breakpoints
374+
// the tick orientation is interpolated.
375375
tickOrientation: {
376376
dependentOn: 'width',
377-
mapping: { 0: 90, 3: 0}
377+
breakpointValues: { 0: 90, 2: 0}
378378
}
379379
},
380380
y: {
@@ -415,10 +415,8 @@ const args = {
415415
...
416416
series: {
417417
...
418-
markerTooltips: {
419-
tooltips: function (_, {xValue, yValue}) {
420-
return \`Year: \${xValue}<br/>Students: \${format('.2f')(yValue)}\`
421-
},
418+
markerTooltipGenerator: function (_, {xValue, yValue}) {
419+
return \`Year: \${xValue}<br/>Students: \${format('.2f')(yValue)}\`
422420
},
423421
labels: {
424422
values: students.map(student => student.toString()),

0 commit comments

Comments
 (0)