官术网_书友最值得收藏!

Creating a line chart with variable width lines

This is an interesting technique that has some rare enough applications. However, it could be a useful one to have in your arsenal.

I used it to create my Homage to Minard (http://qliktips.blogspot.ie/2012/06/homage-to-minard.html).

Getting ready

Load the following script:

LOAD * INLINE [
    Country, Sales, Target, Month
    USA, 1000, 1500, 2013-01-01
    USA, 1200, 1600, 2013-02-01
    USA, 3500, 1800, 2013-03-01
    USA, 2500, 2000, 2013-04-01
    USA, 3000, 2500, 2013-05-01
    USA, 2500, 3000, 2013-06-01
    UK, 1000, 1500, 2013-01-01
    UK, 1700, 1600, 2013-02-01
    UK, 2200, 1800, 2013-03-01
    UK, 2000, 2000, 2013-04-01
    UK, 1300, 2500, 2013-05-01
    UK, 1900, 3000, 2013-06-01
];

How to do it…

These steps will show you how to create a line chart with variable width lines:

  1. Create a new line chart. Add Month and Country as dimensions.
  2. On the Expressions tab, add this expression:
    Sum(Sales)
  3. Click on the + sign beside the expression and enter this expression for the Line Style property:
    ='<W' & 
    Round(0.5 + (7 * Sum(Sales)/Sum(Target)), 0.1) 
    & '>'
  4. Still on the Expressions tab, in the Display Options section, select Symbol and select Dots from the drop-down menu:
  5. Set the Line Width property to 1 pt and the Symbol Size property to 2 pt. Click on Finish:
  6. The chart shows the values as normal; however, the lines are thicker where performance versus target is better:

How it works…

The Line Style property allows you to specify a width attribute for the line chart. This is a tag in the format:

<Wn.n>

Where, n.n is a number between 0.5 and 8.0.

We use the Round function here to round the value down to one decimal place.

We add the dots style symbol because they help fill in some gaps in the lines, especially where there are sharper corners.

There's more…

There are a few applications of this. In the same blog post as the Minard chart, I have shown an image of a chart using this function and a smooth line option.

主站蜘蛛池模板: 武冈市| 砚山县| 论坛| 光山县| 紫金县| 铜川市| 贵州省| 五莲县| 满洲里市| 鄂托克旗| 湘乡市| 南昌县| 冀州市| 武隆县| 特克斯县| 雷波县| 延庆县| 利川市| 沙湾县| 法库县| 南岸区| 玉树县| 孙吴县| 巴塘县| 德安县| 玛纳斯县| 甘德县| 四平市| 永春县| 宜良县| 南和县| 乐亭县| 河间市| 富平县| 阿克苏市| 卓尼县| 曲麻莱县| 巫山县| 尤溪县| 泊头市| 杨浦区|