Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions viz-lib/src/visualizations/chart/Editor/GeneralSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import React, { useMemo } from "react";
import { Section, Select, Checkbox, InputNumber, ContextHelp, Input } from "@/components/visualizations/editor";
import { UpdateOptionsStrategy } from "@/components/visualizations/editor/createTabbedEditor";
import { EditorPropTypes } from "@/visualizations/prop-types";
import * as Grid from "antd/lib/grid";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we avoid using import *? It would be better to see the module properties this line is intended to import

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 5b0ba9c .

import { cleanNumber } from "../plotly/utils";

import ChartTypeSelect from "./ChartTypeSelect";
import ColumnMappingSelect from "./ColumnMappingSelect";
Expand Down Expand Up @@ -343,6 +345,43 @@ export default function GeneralSettings({ options, data, onOptionsChange }: any)
</Section>
)}

{includes(["heatmap"], options.globalSeriesType) && (
<React.Fragment>
{/* @ts-expect-error ts-migrate(2745) FIXME: This JSX tag's 'children' prop expects type 'never... Remove this comment to see the full error message */}
<Section>
<InputNumber
label="Brick Spacing"
data-test="Chart.HeatmapSpacing"
defaultValue={options.heatmapSpacing}
onChange={(value: any) => onOptionsChange({ heatmapSpacing: toNumber(value) })}
/>
</Section>
{/* @ts-expect-error ts-migrate(2745) FIXME: This JSX tag's 'children' prop expects type 'never... Remove this comment to see the full error message */}
<Section>
{/* @ts-expect-error ts-migrate(2322) FIXME: Type '{ children: Element[]; gutter: number; type:... Remove this comment to see the full error message */}
<Grid.Row gutter={15} type="flex" align="middle">
<Grid.Col span={12}>
<InputNumber
label="Color Column Min Value"
placeholder="Auto"
data-test="Chart.RangeZMin"
defaultValue={cleanNumber(options.rangeZMin)}
onChange={(value: any) => onOptionsChange({ rangeZMin: toNumber(value) })}
/>
</Grid.Col>
<Grid.Col span={12}>
<InputNumber
label="Color Column Max Value"
placeholder="Auto"
data-test="Chart.RangeZMax"
defaultValue={cleanNumber(options.rangeZMax)}
onChange={(value: any) => onOptionsChange({ rangeZMax: toNumber(value) })}
/>
</Grid.Col>
</Grid.Row>
</Section>
</React.Fragment>
)}
{/* @ts-expect-error ts-migrate(2745) FIXME: This JSX tag's 'children' prop expects type 'never... Remove this comment to see the full error message */}
<Section>
<Checkbox
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@
"colorscale": [
[ 0, "rgb(0,0,255)" ],
[ 1, "rgb(255,0,0)" ]
]
],
"zmin": false,
"zmax": false,
"xgap": 0,
"ygap": 0
}
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,11 @@
"colorscale": [
[ 0, "rgb(0,0,255)" ],
[ 1, "rgb(255,0,0)" ]
]
],
"zmin": false,
"zmax": false,
"xgap": 0,
"ygap": 0
}
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@
"colorscale": [
[ 0, "rgb(0,0,255)" ],
[ 1, "rgb(255,0,0)" ]
]
],
"zmin": false,
"zmax": false,
"xgap": 0,
"ygap": 0
}
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,11 @@
"colorscale": [
[ 0, "rgb(0,0,255)" ],
[ 1, "rgb(255,0,0)" ]
]
],
"zmin": false,
"zmax": false,
"xgap": 0,
"ygap": 0
}
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,11 @@
"colorscale": [
[ 0, "rgb(0,0,0)" ],
[ 1, "rgb(255,255,255)" ]
]
],
"zmin": false,
"zmax": false,
"xgap": 0,
"ygap": 0
},
{
"x": [12, 11, 12, 11],
Expand Down
4 changes: 4 additions & 0 deletions viz-lib/src/visualizations/chart/plotly/prepareHeatmapData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ function prepareSeries(series: any, options: any, additionalOptions: any) {
type: "heatmap",
name: "",
colorscale: colorScheme,
xgap: (options.heatmapSpacing || 0) * 0.2,
ygap: (options.heatmapSpacing || 0) * 0.2,
Copy link
Collaborator

@eradman eradman Oct 27, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do not need to divide the user input. If the user wants a very faint line they can input 0.2

Copy link
Contributor Author

@deecay deecay Oct 27, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in [fcf6e1b].

zmin: options.rangeZMin || false,
zmax: options.rangeZMax || false,
};

// @ts-expect-error ts-migrate(2322) FIXME: Type 'any[]' is not assignable to type 'never[]'.
Expand Down
11 changes: 11 additions & 0 deletions viz-lib/src/visualizations/chart/plotly/prepareLayout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,15 @@ function prepareBoxLayout(layout: any, options: any, data: any) {
return layout;
}

function prepareHeatmapLayout(layout: any, options: any, data: any) {
layout = prepareDefaultLayout(layout, options, data);
layout.xaxis.showgrid = false;
layout.xaxis.zeroline = false;
layout.yaxis.showgrid = false;
layout.yaxis.zeroline = false;
return layout;
}

export default function prepareLayout(element: any, options: any, data: any) {
const layout = {
margin: { l: 10, r: 10, b: 5, t: 20, pad: 4 },
Expand All @@ -129,6 +138,8 @@ export default function prepareLayout(element: any, options: any, data: any) {
return preparePieLayout(layout, options, data);
case "box":
return prepareBoxLayout(layout, options, data);
case "heatmap":
return prepareHeatmapLayout(layout, options, data);
default:
return prepareDefaultLayout(layout, options, data);
}
Expand Down