-
Notifications
You must be signed in to change notification settings - Fork 188
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(core): add support for horizontal bar charts (#415)
* feat(core): add support for horizontal bar charts * add stories for horizontal bar * add horizontal discrete bar chart * add vue and angular stories * update zero-line transition * Update packages/core/src/components/graphs/bar-stacked.ts Co-Authored-By: Cal Smith <[email protected]> * enable switching orientations for grouped bar without duplicating draw logic * fix lint errors * draw simple bars in horizontal & vertical orientations * draw stacked bars regardless of 2D orientation * add orientation support for time-series stacked bar charts * use the calculated bar width in all 3 bar types * add requested PR changes * fix lint error * fix lint error * fix tests * fix lint error * fix tests tsconfig issue * add knobs to all stories * add requested PR changes * code style changes * code style fixes Co-authored-by: Eliad Moosavi <[email protected]> Co-authored-by: Cal Smith <[email protected]>
- Loading branch information
1 parent
b4191b3
commit 6a480f0
Showing
37 changed files
with
976 additions
and
439 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
import { storiesOf } from "@storybook/angular"; | ||
import { withKnobs, object } from "@storybook/addon-knobs"; | ||
|
||
import { ChartsModule } from "../src/charts.module"; | ||
|
||
import { | ||
// Horizontal bar | ||
groupedHorizontalBarOptions, | ||
groupedHorizontalBarData, | ||
simpleHorizontalBarOptions, | ||
simpleHorizontalBarData, | ||
simpleHorizontalBarTimeSeriesOptions, | ||
simpleHorizontalBarTimeSeriesData, | ||
stackedHorizontalBarTimeSeriesOptions, | ||
stackedHorizontalBarTimeSeriesData, | ||
stackedHorizontalBarData, | ||
stackedHorizontalBarOptions, | ||
} from "../../core/demo/demo-data/index"; | ||
import { addWidthAndHeight } from "./commons"; | ||
|
||
const template = barType => ` | ||
<ibm-${barType}-bar-chart | ||
class="n-chart" | ||
[data]="data" | ||
[options]="options" | ||
#${barType}BarChart> | ||
</ibm-${barType}-bar-chart> | ||
`; | ||
|
||
const stories = storiesOf("Bar (Horizontal)", module).addDecorator(withKnobs); | ||
stories.add(simpleHorizontalBarOptions.title, () => ({ | ||
template: template("simple"), | ||
moduleMetadata: { | ||
imports: [ChartsModule] | ||
}, | ||
props: { | ||
data: object("Data", simpleHorizontalBarData), | ||
options: object("Options", addWidthAndHeight(simpleHorizontalBarOptions)) | ||
} | ||
})); | ||
|
||
stories.add(simpleHorizontalBarTimeSeriesOptions.title, () => ({ | ||
template: template("simple"), | ||
moduleMetadata: { | ||
imports: [ChartsModule] | ||
}, | ||
props: { | ||
data: object("Data", simpleHorizontalBarTimeSeriesData), | ||
options: object("Options", addWidthAndHeight(simpleHorizontalBarTimeSeriesOptions)) | ||
} | ||
})); | ||
|
||
stories.add(groupedHorizontalBarOptions.title, () => ({ | ||
template: template("grouped"), | ||
moduleMetadata: { | ||
imports: [ChartsModule] | ||
}, | ||
props: { | ||
data: object("Data", groupedHorizontalBarData), | ||
options: object("Options", addWidthAndHeight(groupedHorizontalBarOptions)) | ||
} | ||
})); | ||
|
||
stories.add(stackedHorizontalBarOptions.title, () => ({ | ||
template: template("stacked"), | ||
moduleMetadata: { | ||
imports: [ChartsModule] | ||
}, | ||
props: { | ||
data: object("Data", stackedHorizontalBarData), | ||
options: object("Options", addWidthAndHeight(stackedHorizontalBarOptions)) | ||
} | ||
})); | ||
|
||
stories.add(stackedHorizontalBarTimeSeriesOptions.title, () => ({ | ||
template: template("stacked"), | ||
moduleMetadata: { | ||
imports: [ChartsModule] | ||
}, | ||
props: { | ||
data: object("Data", stackedHorizontalBarTimeSeriesData), | ||
options: object("Options", addWidthAndHeight(stackedHorizontalBarTimeSeriesOptions)) | ||
} | ||
})); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.