|
| 1 | +@attribute [Route(pageUrl)] |
| 2 | +@layout DemosMainLayout |
| 3 | + |
| 4 | +<PageMetaTags PageUrl="@pageUrl" Title="@metaTitle" Description="@metaDescription" ImageUrl="@imageUrl" /> |
| 5 | + |
| 6 | +<PageHero Title="@pageTitle"> |
| 7 | + <SubTitleTemplate> |
| 8 | + @((MarkupString)pageDescription) |
| 9 | + </SubTitleTemplate> |
| 10 | +</PageHero> |
| 11 | + |
| 12 | +<DocsLink Href="@DemoRouteConstants.Docs_BarChart" /> |
| 13 | + |
| 14 | +<Prerequisites PageUrl="@pageUrl" /> |
| 15 | + |
| 16 | +<Section Class="p-0" Size="HeadingSize.H4" Name="How it works" PageUrl="@pageUrl" Link="how-it-works"> |
| 17 | + <Block> |
| 18 | + The <strong>Bar Chart</strong> component visualizes data as vertical bars, making it easy to compare values across categories or track changes over time. |
| 19 | + <br /><br /> |
| 20 | + <strong>How to use:</strong> |
| 21 | + <div class="content"> |
| 22 | + <ol> |
| 23 | + <li>Add the <code>BarChart</code> component to your page.</li> |
| 24 | + <li>Provide <code>Labels</code> for the X-axis categories and one or more <code>Datasets</code> for the Y-axis values.</li> |
| 25 | + <li>Customize appearance and behavior using the <code>Options</code> property (e.g., colors, tooltips, axis settings).</li> |
| 26 | + <li>Refer to the demo code for examples of basic and advanced usage, including multiple datasets and custom styling.</li> |
| 27 | + </ol> |
| 28 | + </div> |
| 29 | + This demo showcases the essential setup for a bar chart and demonstrates how to bind your data for quick visualization. |
| 30 | + </Block> |
| 31 | + <Demo Type="typeof(BarChart_Demo_01_Examples)" Tabs="true" /> |
| 32 | +</Section> |
| 33 | + |
| 34 | +<Section Class="p-0" Size="HeadingSize.H4" Name="Combo bar/line" PageUrl="@pageUrl" Link="combo-bar-line"> |
| 35 | + <Block> |
| 36 | + The <strong>Combo bar/line</strong> demo mixes <code>BarChartDataset</code> and <code>LineChartDataset</code> in the same <code>BarChart</code>. |
| 37 | + <br /><br /> |
| 38 | + <strong>How to use:</strong> |
| 39 | + <div class="content"> |
| 40 | + <ol> |
| 41 | + <li>Use the <code>BarChart</code> component as the root chart.</li> |
| 42 | + <li>Add both <code>BarChartDataset</code> and <code>LineChartDataset</code> instances to the same <code>ChartData.Datasets</code> collection.</li> |
| 43 | + <li>Configure interaction options such as <code>Mode = InteractionMode.Index</code> and <code>Intersect = false</code> for a combined tooltip experience.</li> |
| 44 | + <li>Refer to the demo code below for a working example with bar columns and a line overlay.</li> |
| 45 | + </ol> |
| 46 | + </div> |
| 47 | + </Block> |
| 48 | + <Demo Type="typeof(BarChart_Demo_09_Combo_Bar_Line)" Tabs="true" /> |
| 49 | +</Section> |
| 50 | + |
| 51 | +<Section Class="p-0" Size="HeadingSize.H4" Name="Horizontal bar chart" PageUrl="@pageUrl" Link="horizontal-bar-chart"> |
| 52 | + <Block> |
| 53 | + The <strong>Horizontal Bar Chart</strong> displays data values as horizontal bars, making it ideal for comparing categories with long labels or when you want to emphasize comparison between values. |
| 54 | + <br /><br /> |
| 55 | + <strong>How to use:</strong> |
| 56 | + <div class="content"> |
| 57 | + <ol> |
| 58 | + <li>Use the <code>BarChart</code> component and set the <code>IndexAxis</code> option to <code>'y'</code> to render bars horizontally.</li> |
| 59 | + <li>Provide your data and labels as you would for a standard bar chart.</li> |
| 60 | + <li>Customize colors and appearance using the available palette utilities or your own color set.</li> |
| 61 | + </ol> |
| 62 | + </div> |
| 63 | + Refer to the demo code below for a working example and configuration options. |
| 64 | + </Block> |
| 65 | + <Demo Type="typeof(BarChart_Demo_02_Horizontal_BarChart)" Tabs="true" /> |
| 66 | +</Section> |
| 67 | + |
| 68 | +<Section Class="p-0" Size="HeadingSize.H4" Name="Stacked bar chart" PageUrl="@pageUrl" Link="stacked-bar-chart"> |
| 69 | + <Block> |
| 70 | + The <strong>Stacked Bar Chart</strong> allows you to display multiple data series stacked on top of each other, making it easy to compare the total and individual contributions of each series for every category. |
| 71 | + <br /><br /> |
| 72 | + <strong>How to use:</strong> |
| 73 | + <div class="content"> |
| 74 | + <ol> |
| 75 | + <li>Use the <code>BarChart</code> component and configure the <code>Options.Scales.X.Stacked</code> and <code>Options.Scales.Y.Stacked</code> properties to <code>true</code> to enable stacking.</li> |
| 76 | + <li>Provide multiple datasets in your chart data, each representing a different series to be stacked.</li> |
| 77 | + <li>Customize colors for each dataset using palette utilities or your own color set for better distinction.</li> |
| 78 | + <li>Refer to the demo code below for a working example and further configuration options.</li> |
| 79 | + </ol> |
| 80 | + </div> |
| 81 | + </Block> |
| 82 | + <Demo Type="typeof(BarChart_Demo_03_Stacked_BarChart)" Tabs="true" /> |
| 83 | +</Section> |
| 84 | + |
| 85 | +<Section Class="p-0" Size="HeadingSize.H4" Name="Stacked bar chart with data labels" PageUrl="@pageUrl" Link="stacked-bar-chart-with-data-labels"> |
| 86 | + <Block> |
| 87 | + The <strong>Stacked Bar Chart with Data Labels</strong> enhances the standard stacked bar chart by displaying value labels directly on each bar segment. This makes it easier to read and compare the values of each dataset within a category. |
| 88 | + <br /><br /> |
| 89 | + <strong>How to use:</strong> |
| 90 | + <ul> |
| 91 | + <li>Use the <code>BarChart</code> component and enable stacking by setting <code>Options.Scales.X.Stacked</code> and <code>Options.Scales.Y.Stacked</code> to <code>true</code>.</li> |
| 92 | + <li>Add multiple datasets to your chart data to represent different series.</li> |
| 93 | + <li>Enable data labels by configuring the chart's plugins, such as <code>Options.Plugins.Datalabels.Display = true</code>.</li> |
| 94 | + <li>Customize the appearance and formatting of data labels as needed for your scenario.</li> |
| 95 | + </ul> |
| 96 | + Refer to the demo code below for a working example and further configuration options. |
| 97 | + </Block> |
| 98 | + <Demo Type="typeof(BarChart_Demo_04_Stacked_BarChart_with_Datalabels)" Tabs="true" /> |
| 99 | +</Section> |
| 100 | + |
| 101 | +<Section Class="p-0" Size="HeadingSize.H4" Name="Locale" PageUrl="@pageUrl" Link="locale"> |
| 102 | + <Block> |
| 103 | + The <strong>Locale</strong> demo shows how to localize number and date formatting in your bar chart. |
| 104 | + <br /><br /> |
| 105 | + <strong>How to use:</strong> |
| 106 | + <div class="content"> |
| 107 | + <ol> |
| 108 | + <li>Set the <code>Locale</code> property on the <code>BarChart</code> component to your desired culture code (e.g., <code>"fr-FR"</code> for French).</li> |
| 109 | + <li>Number and date labels in the chart will automatically format according to the specified locale.</li> |
| 110 | + <li>This is useful for displaying charts to users in different regions with appropriate formatting.</li> |
| 111 | + </ol> |
| 112 | + </div> |
| 113 | + Refer to the demo code below for a working example and configuration options. |
| 114 | + </Block> |
| 115 | + <Demo Type="typeof(BarChart_Demo_05_Locale)" Tabs="true" /> |
| 116 | +</Section> |
| 117 | + |
| 118 | +<Section Class="p-0" Size="HeadingSize.H4" Name="Border radius" PageUrl="@pageUrl" Link="border-radius"> |
| 119 | + <Block> |
| 120 | + The <strong>Border Radius</strong> feature allows you to create bar charts with rounded corners, giving your charts a modern and visually appealing look. This is especially useful for dashboards and applications where aesthetics are important. |
| 121 | + <br /><br /> |
| 122 | + <strong>How to use:</strong> |
| 123 | + <div class="content"> |
| 124 | + <ol> |
| 125 | + <li>Add the <code>BarChart</code> component to your page.</li> |
| 126 | + <li>When defining each <code>BarChartDataset</code>, set the <code>BorderRadius</code> property to a list of pixel values (e.g., <code>new List<double> { 10 }</code>) to control the roundness of the bar corners.</li> |
| 127 | + <li>Optionally, set <code>BorderSkipped = false</code> to apply the border radius to all corners of each bar.</li> |
| 128 | + <li>Customize other appearance options such as <code>BackgroundColor</code> and <code>BorderColor</code> as needed.</li> |
| 129 | + <li>Refer to the demo code below for a working example and further customization options.</li> |
| 130 | + </ol> |
| 131 | + </div> |
| 132 | + Using the <code>BorderRadius</code> property, you can easily enhance the style of your bar charts to better match your application's design. |
| 133 | + </Block> |
| 134 | + <Demo Type="typeof(BarChart_Demo_06_Border_Radius)" Tabs="true" /> |
| 135 | +</Section> |
| 136 | + |
| 137 | +<Section Class="p-0" Size="HeadingSize.H4" Name="Animations - Delay" PageUrl="@pageUrl" Link="animations-delay"> |
| 138 | + <Block> |
| 139 | + The <strong>Animations - Delay</strong> demo illustrates how to add a delay to the animation of your Bar Chart, making the chart elements appear with a timed entrance effect. This is useful for drawing attention to the chart as it loads or for creating a more engaging user experience. |
| 140 | + <br /><br /> |
| 141 | + <strong>How to use:</strong> |
| 142 | + <div class="content"> |
| 143 | + <ol> |
| 144 | + <li>Add the <code>BarChart</code> component to your page and define your <code>Labels</code> and <code>Datasets</code> as usual.</li> |
| 145 | + <li>Configure the <code>Options.Animation</code> property by setting the <code>Duration</code> (in milliseconds) and <code>Delay</code> (in milliseconds) to control the timing of the animation.</li> |
| 146 | + <li>Bind your <code>chartData</code> and <code>barChartOptions</code> to the <code>BarChart</code> component.</li> |
| 147 | + <li>Refer to the demo code below for a working example of how to set up and customize animation delays.</li> |
| 148 | + </ol> |
| 149 | + </div> |
| 150 | + Animation delays help you create visually appealing transitions and can be tailored to fit your application's style. |
| 151 | + </Block> |
| 152 | + <Demo Type="typeof(BarChart_Demo_07_Animations_A_Delay)" Tabs="true" /> |
| 153 | +</Section> |
| 154 | + |
| 155 | +<Section Class="p-0" Size="HeadingSize.H4" Name="Animations - DataSet level delay" PageUrl="@pageUrl" Link="animations-dataset-level-delay"> |
| 156 | + <Block> |
| 157 | + The <strong>Animations - DataSet Level Delay</strong> demo demonstrates how to apply different animation delays to each dataset in your Bar Chart. This allows each dataset to animate in sequence, making comparisons clearer and adding a dynamic effect to your data presentation. |
| 158 | + <br /><br /> |
| 159 | + <strong>How to use:</strong> |
| 160 | + <div class="content"> |
| 161 | + <ol> |
| 162 | + <li>Add the <code>BarChart</code> component to your page and define your <code>Labels</code> and multiple <code>Datasets</code>.</li> |
| 163 | + <li>For each dataset, set the <code>Animation</code> property with specific <code>Duration</code> and <code>Delay</code> values to control when each dataset animates.</li> |
| 164 | + <li>Bind your <code>chartData</code> and <code>barChartOptions</code> to the <code>BarChart</code> component.</li> |
| 165 | + <li>Refer to the demo code below for a practical example of dataset-level animation configuration.</li> |
| 166 | + </ol> |
| 167 | + </div> |
| 168 | + Dataset-level animation delays are ideal for highlighting differences between series and creating engaging, stepwise chart reveals. |
| 169 | + </Block> |
| 170 | + <Demo Type="typeof(BarChart_Demo_08_Animations_B_DataSet_Level_Delay)" Tabs="true" /> |
| 171 | +</Section> |
| 172 | + |
| 173 | +@code { |
| 174 | + private const string pageUrl = DemoRouteConstants.Demos_BarChart; |
| 175 | + private const string pageTitle = "Bar Chart"; |
| 176 | + private const string pageDescription = "The <code>Blazor Bar Chart</code> component displays data values as vertical bars, making it easy to compare multiple data sets or visualize trends over time."; |
| 177 | + private const string metaTitle = "Blazor Bar Chart"; |
| 178 | + private const string metaDescription = "The Blazor Bar Chart component displays data values as vertical bars, making it easy to compare multiple data sets or visualize trends over time."; |
| 179 | + private const string imageUrl = @DemoImageSrcConstants.BarChart; |
| 180 | +} |
0 commit comments