Skip to content

Commit 8a027c8

Browse files
authored
Motion Effects: Add new scroll effect (ChartsCSS#46)
1 parent b11cd56 commit 8a027c8

File tree

1 file changed

+105
-0
lines changed

1 file changed

+105
-0
lines changed

src/customization/motion-effects.md

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,3 +289,108 @@ Grayscale colors the chart when visitors hover over it:
289289
</div>
290290
</template>
291291
</code-example>
292+
293+
## Scroll Effect
294+
295+
Show only part of the data, and allow the user to scroll to view the rest of the data:
296+
297+
```css
298+
#motion-effect {
299+
--total-cells: 11;
300+
--display-cells: 6;
301+
--cell-size: 50px;
302+
303+
width: 100%;
304+
max-width: calc( var( --cell-size ) * var( --display-cells ) );
305+
overflow-x: scroll;
306+
overflow-y: hidden;
307+
scrollbar-gutter: stable;
308+
scrollbar-width: thin;
309+
}
310+
#motion-effect .column {
311+
aspect-ratio: auto;
312+
height: 250px;
313+
width: calc( var( --cell-size ) * var( --total-cells ) );
314+
}
315+
```
316+
317+
<code-example code-example-id="motion-effect-example-5">
318+
<template v-slot:css-code>
319+
#motion-effect-example-5 {
320+
--total-cells: 11;
321+
--display-cells: 6;
322+
--cell-size: 50px;
323+
width: 100%;
324+
max-width: calc( var( --cell-size ) * var( --display-cells ) );
325+
margin: 0 auto;
326+
overflow-x: scroll;
327+
overflow-y: hidden;
328+
scrollbar-gutter: stable;
329+
scrollbar-width: thin;
330+
}
331+
#motion-effect-example-5 .column tbody {
332+
aspect-ratio: auto;
333+
height: 250px;
334+
width: calc( var( --cell-size ) * var( --total-cells ) );
335+
}
336+
</template>
337+
<template v-slot:html-code>
338+
<div id="motion-effect-example-5">
339+
<table class="charts-css column show-labels show-primary-axis show-4-secondary-axes show-data-axes hide-data">
340+
<caption> Motion Effect Example #5 </caption>
341+
<thead>
342+
<tr>
343+
<th scope="col"> Year </th>
344+
<th scope="col"> Progress </th>
345+
</tr>
346+
</thead>
347+
<tbody>
348+
<tr>
349+
<th scope="row"> 2015 </th>
350+
<td style="--size: 1.0;"> <span class="data"> 100 </span> </td>
351+
</tr>
352+
<tr>
353+
<th scope="row"> 2016 </th>
354+
<td style="--size: 0.8;"> <span class="data"> 80 </span> </td>
355+
</tr>
356+
<tr>
357+
<th scope="row"> 2017 </th>
358+
<td style="--size: 0.6;"> <span class="data"> 60 </span> </td>
359+
</tr>
360+
<tr>
361+
<th scope="row"> 2018 </th>
362+
<td style="--size: 0.4;"> <span class="data"> 40 </span> </td>
363+
</tr>
364+
<tr>
365+
<th scope="row"> 2019 </th>
366+
<td style="--size: 0.2;"> <span class="data"> 20 </span> </td>
367+
</tr>
368+
<tr>
369+
<th scope="row"> 2020 </th>
370+
<td style="--size: 0;"> <span class="data"> 0 </span> </td>
371+
</tr>
372+
<tr>
373+
<th scope="row"> 2021 </th>
374+
<td style="--size: 0.2;"> <span class="data"> 20 </span> </td>
375+
</tr>
376+
<tr>
377+
<th scope="row"> 2022 </th>
378+
<td style="--size: 0.4;"> <span class="data"> 40 </span> </td>
379+
</tr>
380+
<tr>
381+
<th scope="row"> 2023 </th>
382+
<td style="--size: 0.6;"> <span class="data"> 60 </span> </td>
383+
</tr>
384+
<tr>
385+
<th scope="row"> 2024 </th>
386+
<td style="--size: 0.8;"> <span class="data"> 80 </span> </td>
387+
</tr>
388+
<tr>
389+
<th scope="row"> 2025 </th>
390+
<td style="--size: 1.0;"> <span class="data"> 100 </span> </td>
391+
</tr>
392+
</tbody>
393+
</table>
394+
</div>
395+
</template>
396+
</code-example>

0 commit comments

Comments
 (0)