Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Non zerobased bar chart #2408

Closed
netil opened this issue Nov 11, 2021 · 4 comments
Closed

Non zerobased bar chart #2408

netil opened this issue Nov 11, 2021 · 4 comments
Labels

Comments

@netil
Copy link
Member

netil commented Nov 11, 2021

Description

Provide new way to draw bar shape.
Specifying the set of start and end data, bar will be drawn for indicated data range, not from the x axis as a baseline.

The dataset will be as:

bb.generate({
	data: {
          columns: [
            ["data1", 
                // specify start/end point
                [10, 140],
                [220, 450],
                [310, 780],
                [270, 770],

               // for numeric value, will work as zerobased as now.
               500,
            ]
        ],
        type: "bar",
    },
});
@netil netil added the feature label Nov 11, 2021
@brianjenkins94
Copy link

This would also be useful for making gantt charts and waterfalls.

@ajaxlab
Copy link
Contributor

ajaxlab commented Nov 19, 2021

@brianjenkins94 We're working for this now 😄

@brianjenkins94
Copy link

brianjenkins94 commented Nov 19, 2021

I was able to accomplish something close enough to a gantt/waterfall using:

const groups = ["offset", "#1111", "#2222", "#3333", "#4444", "#5555", "#6666", "#7777"];

const chart = bb.generate({
	"data": {
		"type": "bar",
		"json": [{"dateCreated":1633113787000,"ticketNumber":"123456","label":"123456","assignee":"John Doe","account":"Acme Corp.","offset":1637016124550,"#1111":93073770,"#2222":95986930,"#3333":58013510,"#4444":4297670,"#5555":1108100,"#6666":5558250,"#7777":502230}],
		"keys": {
			"x": "label",
			"value": groups
		},
		"colors": {
			"offset": "transparent"
		},
		"groups": [groups],
		"order": null
	},
	"axis": {
		"x": {
			"type": "category"
		},
		"y": {
			"min": new Date().setMonth(new Date().getMonth() - 1),
			"max": new Date().getTime(),
			"padding": {
				"top": 0,
				"bottom": 0
			},
			"tick": {
				"format": function(index, categoryName) {
					return new Date(index).toLocaleDateString("en-US");
				}
			}
		},
		"rotated": true
	},
	"legend": {
		"hide": true
	}
});

But it required calculating the offset from the epoch and manually specifying the min/max on the window.

I can put together a codepen if there's interest.

@netil netil closed this as completed in 3588abe Dec 3, 2021
github-actions bot pushed a commit that referenced this issue Dec 17, 2021
# [3.3.0-next.1](3.2.2...3.3.0-next.1) (2021-12-17)

### Bug Fixes

* **text:** Fix text position with candlestick type combination ([f84ab3e](f84ab3e)), closes [#2436](#2436)
* **tooltip:** fix candlestick tooltip display with xs option ([0278067](0278067)), closes [#2434](#2434)

### Features

* **bar:** add non zero based bar chart ([3588abe](3588abe)), closes [#2408](#2408) [#2438](#2438)
* **bar:** Implement stacking bar radius ([8f14d1a](8f14d1a)), closes [#2428](#2428)
* **module:** Support dual CJS/ESM package ([437c007](437c007)), closes [#2202](#2202)
* **option:** Enhance padding to be removed completely ([2052a19](2052a19)), closes [#2367](#2367)
* **plugin:** Intent to ship TableView plugin ([215b611](215b611)), closes [#1873](#1873)
github-actions bot pushed a commit that referenced this issue Jan 14, 2022
# [3.3.0](3.2.2...3.3.0) (2022-01-14)

### Bug Fixes

* **api:** Ensure svg nodes to be removed from memory  ([f49ed83](f49ed83)), closes [#2489](#2489)
* **event:** fix touch event handling on arc ([d3d2e05](d3d2e05)), closes [#2477](#2477)
* **text:** Fix text position with candlestick type combination ([f84ab3e](f84ab3e)), closes [#2436](#2436)
* **tooltip:** fix candlestick tooltip display with xs option ([0278067](0278067)), closes [#2434](#2434)
* **types:** Fix axis types definition ([92fb033](92fb033)), closes [#2499](#2499)
* **types:** Fix plugin's type definition ([f3690f9](f3690f9)), closes [#2483](#2483)

### Features

* **axis:** alow user to hide tick lines while using culling ([aad8c45](aad8c45)), closes [#2478](#2478) [#2480](#2480)
* **bar:** add non zero based bar chart ([3588abe](3588abe)), closes [#2408](#2408) [#2438](#2438)
* **bar:** Implement stacking bar radius ([8f14d1a](8f14d1a)), closes [#2428](#2428)
* **bar:** Intent to ship bar.indices.removeNull ([b16605d](b16605d)), closes [#1687](#1687)
* **option:** Enhance padding to be removed completely ([2052a19](2052a19)), closes [#2367](#2367)
@brianjenkins94
Copy link

brianjenkins94 commented Jul 15, 2022

Do you have to set something to get this feature to work? How do you tell it to expect values to be non-zero-based?

Edit: Oh you pass in an array instead of a value. 🤦‍♂️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants