Creating a Bar Graph with CSS Grid

Post pobrano z: Creating a Bar Graph with CSS Grid

If you’re looking for more manageable ways to create bar graphs, or in search of use cases to practice CSS Grid layout, I got you!

Before we begin working on the graph, I want to talk about coding the bars, when Grid is a good approach for graphs, and we’ll also cover some code choices you might consider before getting started.

Preface

The bar is a pretty basic shape: you can control its dimensions with CSS width, height, number of grid or table cells, etc. depending on how you’ve coded it. As far as graphs go, the main thing we want to control is the height of the bars in the graph.

Controlling height with Grid cells (like here) is convenient for designs where the height is incremental by a fixed value — no in-betweens. For example, signal bars in phones or when you don’t mind setting a lot of grid rows to better control the bar height down to its smallest value, like IRL graph paper.

Five vertical purple bars that get progressively taller from left to right like a signal indicator on a cell phone.

For my graph, I want gradient bars as well as vertical and horizontal axes labels. So, to make it easy, I have decided to control the bar height with gradient sizing, and determine the number of grid rows based on the number of vertical axis labels I want.

Also, other than the contents for the graph — bars, axes labels, and captions — there’ll be no data present in the HTML, like data about bar colors and dimensions.

data-* attributes are used to provide that sort of information in HTML. But I didn’t want to switch back and forth between HTML and CSS while coding, and decided to completely separate the content from the design. It’s totally up to you. If you feel like using data-* might benefit your project, go for it.

I’ve created a diagram below that you might find useful to refer to while reading the code. It depicts the graph and the grid that contains it. The numbers represent grid lines.

Four gold cylindrical bars on a graph where the y-axis goes from 0 to 100 in increments of 10 and the x-axis is labeled with different smiley face emoji.

Let’s code this thing.

The HTML

Grid can automatically place items in top-bottom and left-right directions. To take advantage of that, I’m going to add the graph contents in the order y-axis labels (top-bottom), bars, and x-axis labels (left-right). This way, I only need to write the HTML markup and the CSS will place the bars for me!

<figure aria-hidden="true">
    <div class="graph">
        <span class="graphRowLabel">100</span>
        <span class="graphRowLabel">90</span>
        <span class="graphRowLabel">80</span>
        <span class="graphRowLabel">70</span>
        <span class="graphRowLabel">60</span>
        <span class="graphRowLabel">50</span>
        <span class="graphRowLabel">40</span>
        <span class="graphRowLabel">30</span>
        <span class="graphRowLabel">20</span>
        <span class="graphRowLabel">10</span>
        <div  class="graphBar"></div>
        <div  class="graphBar"></div>
        <div  class="graphBar"></div>
        <div  class="graphBar"></div>
        <div  class="graphBar"></div>
        <span><sup>Y </sup>&frasl;<sub> X</sub></span>
        <span class="graphColumnLabel">😊</span>
        <span class="graphColumnLabel">😄</span>
        <span class="graphColumnLabel">☺️</span>
        <span class="graphColumnLabel">😁</span>
        <span class="graphColumnLabel">😀</span>
    </div>
    <figcaption>Made with CSS Grid 💛</figcaption>
</figure>

<span class="screenreader-text">Smiling face with squinting eyes: 10%, grinning face with squinting eyes: 65%, smiling face: 52%, grinning face with smiling eyes: 100%, and grinning face: 92%.</span>

Note: If you’re interested in accessibility, know that I’m not an accessibility expert. But when I tried to make the bars accessible, screen reader experience simply sucked. Using aria-labelledby wasn’t that good either. So, I added a text description of the graph and hid it from the visual display. That made the reading much more natural.

The CSS

This is where the magic happens.

/* The grid container */
.graph {
  display: grid;
  grid:  repeat(10, auto) max-content / max-content repeat(5, auto);
  /* ... */
}

We’ve defined eleven rows and six columns in our grid with these two little lines of CSS: ten automatically sized rows and one sized to its „maximum content”; one column sized to its „maximum content” and five automatically sized. CSS Grid is a beautiful thing.

The graph bars need to cover the grid from the first row to the second-to-last row since we are using the last one for the x-axis labels. I gave the bars 100% height, and grid-row: 1 / -2; which means „span the items from first horizontal grid line till the second last.”

/* A grid item */
.graphBar{
  height: 100%;
  grid-row: 1 / -2;
}

The bars also have linear gradient going upwards. The size of the colored portion of the gradient is the indicator of bar’s height, which in turn is taken from each bar’s own CSS rule as a custom variable.

/* A grid item */
.graphBar{
  /* Same as before */
  background: palegoldenrod linear-gradient(to top, gold var(--h), transparent var(--h));
}

To control the width of the bars and the space between them, I use a fixed width and centered them with justify-self: center;. You can instead use grid-column-gap to create gaps between columns if you want. Here’ the full code that pulls everything for the bars together:

/* A grid item */
.graphBar{
  height: 100%;
  grid-row: 1 / -2;
  background: palegoldenrod linear-gradient(to top, gold var(--h), transparent var(--h));
  width: 45px;
  justify-self: center;
}

Did you notice the CSS variable (var(--h)) in there? We need to specify the exact height of each bar and we can use the variable to determine the height of the background gradient in terms of percentage:

.graphBar:nth-of-type(1) {
  grid-column: 2;
  --h: 10%;
}
.graphBar:nth-of-type(2) {
  grid-column: 3;
  --h: 65%;
}
.graphBar:nth-of-type(3) {
  grid-column: 4;
  --h: 52%;
}
/* and so on... */

That’s it! after styling, the graph looks like this:

See the Pen CSS Bar Graph with Grid by Preethi (@rpsthecoder) on CodePen.

There are a few demo-specific styles in here but everything we’ve covered so far will get you the basic framework for a bar graph. The y-axis labels I created are positioned on top of the grid lines for a slightly cleaner layout. I got the cylindrical shape and the cross-section edges of the bars by using border-radius and elliptic pseudo elements, respectively. Without them, you’ll get a straight up rectangular bar.

The post Creating a Bar Graph with CSS Grid appeared first on CSS-Tricks.

4 Ways to Improve Quality Assurance

Post pobrano z: 4 Ways to Improve Quality Assurance

A lot of people tend to think of quality assurance and quality control to be the same but they are not. They may be used interchangeably but there’s a vast difference between the two.

Quality assurance is more inclined towards looking at how processes are performed and products standards are met, while quality control is about inspecting how the process is going through. For a business to run smoothly, both factors need to be paid attention to.


Fooling around by Jippen Jooste

Quality assurance is necessary to ensure that products and services are made and delivered at their best. It helps in keeping existing customers loyal for a long time. Moreover, it helps improve workflow, eliminate mistakes, and more importantly, ensure that only quality products reach the market. This is very important because a business can take a serious hit if it produces poor quality products as such a move can affect its brand and cause it to fail.

Quality assurance is often done with software to figure out weaknesses in the quality of products. These weaknesses are then eliminated by adapting the preventive measures.

In short, quality assurance is the tool used to assure that the quality of products is highly maintained. Businesses need to do this to be able to stay ahead of the pack.

Moreover, they also need to Protect Your Data, continue to come up with newer and better products at affordable rates to ensure that they grow. Now without much ado, let’s have a look at four ways to improve quality assurance:

1. Inspect Products for Performance

It’s not smart to let teams work on their own without any monitoring. There’s a window for error and people working in the quality assurance departments need to understand that. Regular performance checks on employees and products being manufactured should be conducted. It helps to figure out errors and mistakes if there are any.

Early performance inspections will help give you enough time to correct errors and mistakes before the final stage of manufacturing is completed. Waiting for the last moment will cost more money, more time and will even result in a waste of resources and efforts.

2. Take Customer Input

The best way to improve quality assurance is to take customer complaints seriously. No business can shine and thrive if they keep on disappointing customers with the products they sell or the services they offer. The trick lies in conducting customer surveys and learning about the areas where you can improve. For example, most customers these days want to know how businesses protect data and apps. This is important with data breaches becoming a common occurrence.

If your customers appear to be concerned about this factor, you can educate them about how you ensure the safety of their data to satisfy them. Customer feedback can be taken in a variety of ways such as online surveys, walk-in forms etc.

3. Conduct Tests Right From The Beginning

Many businesses wait until all requirements are met to finally conduct a QA test to ensure everything is right. However, it is recommended to begin taking tests right from the initial stages so that problems can be found and corrected in the beginning.

The best part of conducting tests, in the beginning, is that it will reduce cost on a huge scale because you won’t be dealing with large-scale problems at the end.


Crunching by William Iven

4. Automating Where Possible

There are many ways to improve quality assurance and automating processes where applicable is one of them. This is done by using a quality management software that monitors all processes.

There are many benefits of doing so. It does not only help you save time and money, it also improves customer loyalty as the use of such tools improve overall quality. QA can differ for different businesses but the end-goal remains the same.

Featured image by Jefferson Santos

Why it is Fundamental for Businesses to be Creative with Apps in 2018

Post pobrano z: Why it is Fundamental for Businesses to be Creative with Apps in 2018

The business landscape is a rapidly changing one, a fact that rings especially true when it comes to the manner in which people communicate and expect to be able to access the offerings of big companies.

In the past, companies in sectors like retail, gambling, and even travel, had to adapt to ensure their customers were able to make use of visually appealing websites that were also easy to navigate and frustration-free from start to finish. The aim was to ensure that customers felt they were getting a great customer experience online, in precisely the same manner as they would expect solid customer service in physical stores. Nowadays though, especially in the EU following the introduction of GDPR (which has impacted upon apps as well as websites), it is proving difficult to retain loyal customers through a website presence alone.


Circles Photo by Ashley Kirk

Indeed, with sites as huge as MSN having failed in the past before seismic events like GDPR to keep up with the times, we could start to see a similar experience in the near future if businesses fail to realize the importance of having a creative and engaging app, something that has the potential to keep customers loyal to a brand.

Not just a waste of screen space

The buzz surrounding apps is perhaps not quite as noisy as it was at the height of their publicity back in 2016, especially as growth in using them has slowed slightly, but there is no denying the fact that they are still a vital element for many businesses. There may well be millions (perhaps even tens of millions) of apps that are redundant, but companies that push creativity as part of their app design process are keeping apps at the forefront of their marketing efforts.

This importance is particularly telling in crowded marketplaces like the iGaming world, where having the right app can be the difference between success and failure. In such crowded marketplaces, brands that fail to have an engaging app that allows players to game on the go and take advantage of timely offers can prove to be make or break. For companies like Lottoland, who spend time and money on making apps and websites that are geo-location specific, having this extra outlet that can allow consumers to stay up to date with their winnings wherever they are in the world without being near a computer means that they can attract loyal customers who end up wanting to stay with them for longer.

More than just games

The iGaming world may be an example of an industry where apps can prove the difference between success and failure, but it isn’t the only one. In fact, a recent list of the top ten apps used includes none from the world of gaming; not even Pokemon Go or Candy Crush get a look in. What this shows is that the big tech players like Facebook, Snapchat, and even Google are all aware that the way people browse and use the internet has changed, meaning that a more personalized approach through an app is going to be a more positive experience for a consumer than a blanket approach on a mobile site.
Photo by Christian Wiediger
With this in mind, companies looking to get the fundamentals right in 2018 should make sure that they don’t just have an app created as a gesture, but one that really makes their customers want to download and use it every day.

Featured image by Rami Al-zayat

18 Astonishing Examples of Accounting Print Design

Post pobrano z: 18 Astonishing Examples of Accounting Print Design

Print marketing material can set the tone for your business. For accounting, you want to make sure you give off a professional vibe, but still stand out from the competition. This is the case from business cards to envelopes and everything in between-and managing all of that can be difficult.

Just because you’re an accountant doesn’t mean your design needs to be full of numbers and math symbols. Playing with various colors and imprint methods can do the trick. Still, need more help? Check out these 18 awesome examples to get you started on your design.


















Agregator najlepszych postów o designie, webdesignie, cssie i Internecie