aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbobzel <zzzman@gmail.com>2023-08-27 13:31:46 -0400
committerbobzel <zzzman@gmail.com>2023-08-27 13:31:46 -0400
commit0332a80329328e39c244623d5090331b83df339c (patch)
treec761c0b161face4eea1eaff276c4c220a3b72c85
parent2df1f976b5f79213299ea7169c9ded8b216dee6e (diff)
minor cleanup of componentDidMount stuff for dataViz
-rw-r--r--src/client/documents/Documents.ts2
-rw-r--r--src/client/views/nodes/DataVizBox/DataVizBox.tsx8
-rw-r--r--src/client/views/nodes/DataVizBox/components/Histogram.tsx1
-rw-r--r--src/client/views/nodes/DataVizBox/components/LineChart.tsx3
-rw-r--r--src/client/views/nodes/DataVizBox/components/PieChart.tsx1
5 files changed, 4 insertions, 11 deletions
diff --git a/src/client/documents/Documents.ts b/src/client/documents/Documents.ts
index 5b68c2d84..7f3309ea8 100644
--- a/src/client/documents/Documents.ts
+++ b/src/client/documents/Documents.ts
@@ -689,7 +689,7 @@ export namespace Docs {
DocumentType.DATAVIZ,
{
layout: { view: DataVizBox, dataField: defaultDataKey },
- options: { dataViz_title: '', dataViz: 'table', _layout_fitWidth: true, nativeDimModifiable: true },
+ options: { dataViz_title: '', dataViz_line: '', dataViz_pie: '', dataViz_histogram: '', dataViz: 'table', _layout_fitWidth: true, nativeDimModifiable: true },
},
],
[
diff --git a/src/client/views/nodes/DataVizBox/DataVizBox.tsx b/src/client/views/nodes/DataVizBox/DataVizBox.tsx
index b14525993..b9db5fe15 100644
--- a/src/client/views/nodes/DataVizBox/DataVizBox.tsx
+++ b/src/client/views/nodes/DataVizBox/DataVizBox.tsx
@@ -35,12 +35,8 @@ export class DataVizBox extends ViewBoxAnnotatableComponent<FieldViewProps>() {
// all CSV records in the dataset (that aren't an empty row)
@computed.struct get records() {
- var records = DataVizBox.dataset.get(CsvCast(this.rootDoc[this.fieldKey]).url.href)
- var nonEmptyRecords = records?.filter(record => {
- var notEmpty = false;
- Object.keys(record).forEach(key => { if (record[key]!=undefined && record[key]!="") notEmpty = true});
- return notEmpty})
- return nonEmptyRecords;
+ var records = DataVizBox.dataset.get(CsvCast(this.rootDoc[this.fieldKey]).url.href);
+ return records?.filter(record => Object.keys(record).some(key => record[key]));
}
// currently chosen visualization type: line, pie, histogram, table
diff --git a/src/client/views/nodes/DataVizBox/components/Histogram.tsx b/src/client/views/nodes/DataVizBox/components/Histogram.tsx
index 1d8ab8f2a..e67e2bf31 100644
--- a/src/client/views/nodes/DataVizBox/components/Histogram.tsx
+++ b/src/client/views/nodes/DataVizBox/components/Histogram.tsx
@@ -106,7 +106,6 @@ export class Histogram extends React.Component<HistogramProps> {
({ dataSet, w, h }) => dataSet!.length > 0 && this.drawChart(dataSet, w, h),
{ fireImmediately: true }
);
- if (!this.props.layoutDoc.dataViz_histogram) this.props.layoutDoc.dataViz_histogram = '';
};
@action
diff --git a/src/client/views/nodes/DataVizBox/components/LineChart.tsx b/src/client/views/nodes/DataVizBox/components/LineChart.tsx
index 8967f27b8..a69d309dc 100644
--- a/src/client/views/nodes/DataVizBox/components/LineChart.tsx
+++ b/src/client/views/nodes/DataVizBox/components/LineChart.tsx
@@ -76,7 +76,7 @@ export class LineChart extends React.Component<LineChartProps> {
// return selected x and y axes
// otherwise, use the selection of whatever is linked to us
const incomingVizBox = DocumentManager.Instance.getFirstDocumentView(this.parentViz)?.ComponentView as DataVizBox;
- const highlitedRowIds = incomingVizBox && incomingVizBox.rootDoc ? NumListCast(incomingVizBox.rootDoc.dataViz_highlitedRows) : [];
+ const highlitedRowIds = NumListCast(incomingVizBox?.rootDoc?.dataViz_highlitedRows);
return this._tableData.filter((record, i) => highlitedRowIds.includes(this._tableDataIds[i])); // get all the datapoints they have selected field set by incoming anchor
}
@computed get rangeVals(): { xMin?: number; xMax?: number; yMin?: number; yMax?: number } {
@@ -347,7 +347,6 @@ export class LineChart extends React.Component<LineChartProps> {
}
render() {
- this.componentDidMount();
var titleAccessor: any = '';
if (this.props.axes.length == 2) titleAccessor = 'dataViz_lineChart_title' + this.props.axes[0] + '-' + this.props.axes[1];
else if (this.props.axes.length > 0) titleAccessor = 'dataViz_lineChart_title' + this.props.axes[0];
diff --git a/src/client/views/nodes/DataVizBox/components/PieChart.tsx b/src/client/views/nodes/DataVizBox/components/PieChart.tsx
index 6ad9e0d7e..4e23a114a 100644
--- a/src/client/views/nodes/DataVizBox/components/PieChart.tsx
+++ b/src/client/views/nodes/DataVizBox/components/PieChart.tsx
@@ -94,7 +94,6 @@ export class PieChart extends React.Component<PieChartProps> {
},
{ fireImmediately: true }
);
- if (!this.props.layoutDoc.dataViz_pie) this.props.layoutDoc.dataViz_pie = '';
};
@action