Skip to content

Commit

Permalink
refactor: Relocating/renaming various chart controls (apache#836)
Browse files Browse the repository at this point in the history
* refactor: relocating/renaming various chart controls

* typo

* Reverting to "additional metadata"
  • Loading branch information
rusackas authored and zhaoyongjie committed Nov 17, 2021
1 parent 3e362ab commit d463f03
Show file tree
Hide file tree
Showing 16 changed files with 33 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ export const annotations = {
default: [],
description: 'Annotation Layers',
renderTrigger: true,
tabOverride: 'data',
},
},
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ export type InternalControlType =
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export type ControlType = InternalControlType | React.ComponentType<any>;

export type TabOverride = 'data' | boolean;
export type TabOverride = 'data' | 'customize' | boolean;

/**
* Control config specifying how chart controls appear in the control panel, all
Expand All @@ -179,7 +179,8 @@ export type TabOverride = 'data' | boolean;
* show a warning based on the value of another component. It's also possible to bind
* arbitrary data from the redux store to the component this way.
* - tabOverride: set to 'data' if you want to force a renderTrigger to show up on the `Data`
* tab, otherwise `renderTrigger: true` components will show up on the `Style` tab.
tab, or 'customize' if you want it to show up on that tam. Otherwise sections with ALL
`renderTrigger: true` components will show up on the `Customize` tab.
* - visibility: a function that uses control panel props to check whether a control should
* be visibile.
*/
Expand All @@ -198,7 +199,6 @@ export interface BaseControlConfig<
error?: ReactNode;
// override control panel state props
mapStateToProps?: (state: ControlPanelState, control: this) => ExtraControlProps;
tabOverride?: TabOverride;
visibility?: (props: ControlPanelsContainerProps) => boolean;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class CategoricalColorScale extends ExtensibleFunction {
* @returns an object where the key is the data value and the value is the hex color code
*/
getColorMap() {
const colorMap: { [key: string]: string } = {};
const colorMap: { [key: string]: string | undefined } = {};
this.scale.domain().forEach(value => {
colorMap[value.toString()] = this.scale(value);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export default class SequentialScheme extends ColorScheme {
const piecewiseScale: (t: number) => string = piecewise(interpolateHcl, this.colors);
const adjustExtent = scaleLinear().range(extent).clamp(true);

// @ts-ignore
return quantize<string>(t => piecewiseScale(adjustExtent(t)), numColors);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ export default {
{
label: t('Chart Options'),
expanded: true,
tabOverride: 'customize',
controlSetRows: [
['linear_color_scheme'],
[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@ export default {
controlSetRows: [['entity'], ['metric'], ['adhoc_filters']],
},
{
label: t('Options'),
label: t('Chart Options'),
expanded: true,
tabOverride: 'customize',
controlSetRows: [
[
{
Expand Down Expand Up @@ -88,9 +89,9 @@ export default {
],
controlOverrides: {
entity: {
label: t('ISO 3166-2 codes of region/province/department'),
label: t('ISO 3166-2 Codes'),
description: t(
"It's ISO 3166-2 of your region/province/department in your table. (see documentation for list of ISO 3166-2)",
'Column containing ISO 3166-2 codes of region/province/department in your table.',
),
},
metric: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const config: ControlPanelConfig = {
name: 'all_columns_x',
config: {
type: 'SelectControl',
label: t('Column containing event names'),
label: t('Event Names'),
description: t('Columns to display'),
mapStateToProps: state => ({
choices: columnChoices(state?.datasource),
Expand Down Expand Up @@ -98,7 +98,7 @@ const config: ControlPanelConfig = {
config: {
type: 'SelectControl',
multi: true,
label: t('Meta data'),
label: t('Metadata'),
default: [],
description: t('Select any columns for metadata inspection'),
optionRenderer: c => <ColumnOption showType column={c} />,
Expand All @@ -118,11 +118,11 @@ const config: ControlPanelConfig = {
],
controlOverrides: {
entity: {
label: t('Column containing entity ids'),
label: t('Entity ID'),
description: t('e.g., a "user id" column'),
},
row_limit: {
label: t('Event count limit'),
label: t('Max Events'),
description: t('The maximum number of events to return, equivalent to the number of rows'),
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ export default {
controlSetRows: [['groupby'], ['metric'], ['adhoc_filters'], ['row_limit']],
},
{
label: t('Options'),
label: t('Chart Options'),
expanded: true,
controlSetRows: [
[
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export default {
name: 'all_columns_x',
config: {
type: 'SelectControl',
label: 'X',
label: 'X Axis',
default: null,
description: t('Columns to display'),
mapStateToProps: state => ({
Expand All @@ -54,7 +54,7 @@ export default {
name: 'all_columns_y',
config: {
type: 'SelectControl',
label: 'Y',
label: 'Y Axis',
default: null,
description: t('Columns to display'),
mapStateToProps: state => ({
Expand All @@ -72,6 +72,7 @@ export default {
{
label: t('Heatmap Options'),
expanded: true,
tabOverride: 'customize',
controlSetRows: [
['linear_color_scheme'],
[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export default {
name: 'all_columns_x',
config: {
type: 'SelectControl',
label: t('Numeric Columns'),
label: t('Columns'),
default: null,
description: t('Select the numeric columns to draw the histogram'),
mapStateToProps: state => ({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export default {
],
},
{
label: t('Paired t-test'),
label: t('Parameters'),
expanded: false,
controlSetRows: [
[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ export default {
{
label: t('Chart Options'),
expanded: true,
tabOverride: 'customize',
controlSetRows: [
['color_scheme', 'label_colors'],
[
Expand Down Expand Up @@ -192,6 +193,8 @@ export default {
description: t('Use a log scale'),
},
},
],
[
{
name: 'equal_date_size',
config: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export default {
{
label: t('Chart Options'),
expanded: true,
tabOverride: 'customize',
controlSetRows: [
['color_scheme', 'label_colors'],
[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ export default {
},
{
label: t('X Axis'),
tabOverride: 'customize',
expanded: true,
controlSetRows: [
[xAxisLabel, bottomMargin],
Expand All @@ -75,6 +76,7 @@ export default {
},
{
label: t('Y Axis'),
tabOverride: 'customize',
expanded: true,
controlSetRows: [
['y_axis_format', yAxisBounds],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ export default {
{
label: t('Chart Options'),
expanded: true,
tabOverride: 'customize',
controlSetRows: [
['color_scheme', 'label_colors'],
[showLegend, null],
Expand All @@ -69,6 +70,7 @@ export default {
{
label: t('X Axis'),
expanded: true,
tabOverride: 'customize',
controlSetRows: [
[xAxisLabel, leftMargin],
[
Expand Down Expand Up @@ -100,6 +102,7 @@ export default {
{
label: t('Y Axis'),
expanded: true,
tabOverride: 'customize',
controlSetRows: [
[yAxisLabel, bottomMargin],
['y_axis_format', null],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ export default {
controlPanelSections: [
{
label: t('Chart Options'),
tabOverride: 'customize',
expanded: true,
controlSetRows: [
['color_scheme', 'label_colors'],
Expand Down Expand Up @@ -73,7 +74,7 @@ export default {
],
},
{
label: t('Y Axis 1'),
label: t('Y Axis Left'),
expanded: true,
controlSetRows: [
[
Expand Down Expand Up @@ -105,7 +106,7 @@ export default {
],
},
{
label: t('Y Axis 2'),
label: t('Y Axis Right'),
expanded: false,
controlSetRows: [
[
Expand Down

0 comments on commit d463f03

Please sign in to comment.