mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
fixing options issues
This commit is contained in:
parent
55a8b5f87f
commit
f98a4559af
7 changed files with 54 additions and 10 deletions
|
@ -37,6 +37,20 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div class="kuiSideBarFormRow">
|
||||
<label class="kuiSideBarFormRow__label" for="axisScale">
|
||||
Z Axis Scale
|
||||
</label>
|
||||
<div class="kuiSideBarFormRow__control">
|
||||
<select
|
||||
id="axisScale"
|
||||
class="kuiSelect kuiSideBarSelect"
|
||||
ng-model="vis.params.scale"
|
||||
ng-options="mode for mode in vis.type.params.scales"
|
||||
></select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="kuiSideBarFormRow">
|
||||
<label class="kuiSideBarFormRow__label" for="defaultYExtents">
|
||||
Scale to Data Bounds
|
||||
|
|
|
@ -47,6 +47,15 @@ export default function AxisConfigFactory() {
|
|||
const categoryDefaults = {
|
||||
type: 'category',
|
||||
position: 'bottom',
|
||||
};
|
||||
|
||||
const valueDefaults = {
|
||||
labels: {
|
||||
axisFormatter: d3.format('n')
|
||||
}
|
||||
};
|
||||
|
||||
const horizontalDefaults = {
|
||||
labels: {
|
||||
rotate: 0,
|
||||
rotateAnchor: 'end',
|
||||
|
@ -55,9 +64,9 @@ export default function AxisConfigFactory() {
|
|||
}
|
||||
};
|
||||
|
||||
const valueDefaults = {
|
||||
const verticalDefaults = {
|
||||
labels: {
|
||||
axisFormatter: d3.format('n')
|
||||
rotateAnchor: 'middle'
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -67,6 +76,7 @@ export default function AxisConfigFactory() {
|
|||
// _.defaultsDeep mutates axisConfigArgs nested values so we clone it first
|
||||
const axisConfigArgsClone = _.cloneDeep(axisConfigArgs);
|
||||
this._values = _.defaultsDeep({}, axisConfigArgsClone, typeDefaults, defaults);
|
||||
_.merge(this._values, this.isHorizontal() ? horizontalDefaults : verticalDefaults);
|
||||
|
||||
this._values.elSelector = this._values.elSelector.replace('{pos}', this._values.position);
|
||||
this._values.rootEl = chartConfig.get('el');
|
||||
|
@ -114,6 +124,7 @@ export default function AxisConfigFactory() {
|
|||
if (this.isHorizontal() && this.isOrdinal()) {
|
||||
this._values.labels.filter = _.get(axisConfigArgs, 'labels.filter', false);
|
||||
this._values.labels.rotate = _.get(axisConfigArgs, 'labels.rotate', 90);
|
||||
this._values.labels.truncate = _.get(axisConfigArgs, 'labels.truncate', 100);
|
||||
}
|
||||
|
||||
let offset;
|
||||
|
|
|
@ -188,7 +188,7 @@ export default function AxisScaleFactory(Private) {
|
|||
|
||||
if (this.canApplyNice()) this.scale.nice();
|
||||
// Prevents bars from going off the chart when the y extents are within the domain range
|
||||
if (this.visConfig.get('type') === 'histogram' && this.scale.clamp) this.scale.clamp(true);
|
||||
if (this.scale.clamp) this.scale.clamp(true);
|
||||
|
||||
this.validateScale(this.scale);
|
||||
|
||||
|
|
|
@ -76,7 +76,8 @@ export default function ColumnHandler(Private) {
|
|||
|
||||
return function (cfg, data) {
|
||||
const isUserDefinedYAxis = cfg.setYExtents;
|
||||
const config = _.defaults({}, cfg, {
|
||||
const config = _.cloneDeep(cfg);
|
||||
_.defaultsDeep(config, {
|
||||
chartTitle: {},
|
||||
mode: 'normal'
|
||||
}, opts);
|
||||
|
@ -179,11 +180,14 @@ export default function ColumnHandler(Private) {
|
|||
heatmap: (cfg, data) => {
|
||||
const defaults = create()(cfg, data);
|
||||
defaults.valueAxes[0].show = false;
|
||||
defaults.categoryAxes.push({
|
||||
defaults.valueAxes.push({
|
||||
id: 'CategoryAxis-2',
|
||||
type: 'category',
|
||||
position: 'left',
|
||||
values: data.getLabels(),
|
||||
scale: {
|
||||
inverted: true
|
||||
},
|
||||
labels: {
|
||||
axisFormatter: val => val
|
||||
},
|
||||
|
|
|
@ -20,12 +20,13 @@ export default function VisConfigFactory(Private) {
|
|||
|
||||
|
||||
class VisConfig {
|
||||
constructor(visConfigArgs, data, uiState) {
|
||||
constructor(visConfigArgs, data, uiState, el) {
|
||||
this.data = new Data(data, uiState);
|
||||
|
||||
const visType = visTypes[visConfigArgs.type];
|
||||
const typeDefaults = visType(visConfigArgs, this.data);
|
||||
this._values = _.defaultsDeep({}, typeDefaults, DEFAULT_VIS_CONFIG);
|
||||
this._values.el = el;
|
||||
}
|
||||
|
||||
get(property, defaults) {
|
||||
|
|
|
@ -27,8 +27,7 @@ export default function VisFactory(Private) {
|
|||
super(arguments);
|
||||
this.el = $el.get ? $el.get(0) : $el;
|
||||
this.binder = new Binder();
|
||||
this.visConfigArgs = visConfigArgs;
|
||||
this.visConfigArgs.el = this.el;
|
||||
this.visConfigArgs = _.cloneDeep(visConfigArgs);
|
||||
|
||||
// bind the resize function so it can be used as an event handler
|
||||
this.resize = _.bind(this.resize, this);
|
||||
|
@ -67,11 +66,26 @@ export default function VisFactory(Private) {
|
|||
uiState.on('change', this._uiStateChangeHandler);
|
||||
}
|
||||
|
||||
this.visConfig = new VisConfig(this.visConfigArgs, this.data, this.uiState);
|
||||
this.visConfig = new VisConfig(this.visConfigArgs, this.data, this.uiState, this.el);
|
||||
|
||||
const colors = this.getLegendColors();
|
||||
if (colors) {
|
||||
this.uiState.setSilent('vis.defaultColors', null);
|
||||
this.uiState.setSilent('vis.defaultColors', colors);
|
||||
}
|
||||
|
||||
this.handler = new Handler(this, this.visConfig);
|
||||
this._runWithoutResizeChecker('render');
|
||||
}
|
||||
|
||||
getLegendLabels() {
|
||||
return this.visConfig ? this.visConfig.get('legend.labels', null) : null;
|
||||
};
|
||||
|
||||
getLegendColors() {
|
||||
return this.visConfig ? this.visConfig.get('legend.colors', null) : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resizes the visualization
|
||||
*
|
||||
|
|
|
@ -29,7 +29,7 @@ export default function HeatmapChartFactory(Private) {
|
|||
|
||||
addSquares(svg, data) {
|
||||
const xScale = this.getCategoryAxis().getScale();
|
||||
const yScale = this.handler.categoryAxes[1].getScale();
|
||||
const yScale = this.handler.valueAxes[1].getScale();
|
||||
const zScale = this.getValueAxis().getScale();
|
||||
const ordered = this.handler.data.get('ordered');
|
||||
const tooltip = this.baseChart.tooltip;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue