aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/nodes/DataVizBox/components/Histogram.tsx
diff options
context:
space:
mode:
authorbobzel <zzzman@gmail.com>2024-03-10 09:50:46 -0400
committerbobzel <zzzman@gmail.com>2024-03-10 09:50:46 -0400
commit4caca5b32f74beed00bfbdaa181cb69fc001b7ca (patch)
tree5601b1bdaa8499af44d2ca50dd845ea0a65128b4 /src/client/views/nodes/DataVizBox/components/Histogram.tsx
parent3735fd5e8c0f5315d73a28ef59dcff4bc6158c88 (diff)
parenta9eb266296d1b71f1016c867f39e20299c011eea (diff)
Merge branch 'master' into zach-starter
Diffstat (limited to 'src/client/views/nodes/DataVizBox/components/Histogram.tsx')
-rw-r--r--src/client/views/nodes/DataVizBox/components/Histogram.tsx22
1 files changed, 16 insertions, 6 deletions
diff --git a/src/client/views/nodes/DataVizBox/components/Histogram.tsx b/src/client/views/nodes/DataVizBox/components/Histogram.tsx
index a7f292104..6672603f3 100644
--- a/src/client/views/nodes/DataVizBox/components/Histogram.tsx
+++ b/src/client/views/nodes/DataVizBox/components/Histogram.tsx
@@ -20,6 +20,7 @@ export interface HistogramProps {
Document: Doc;
layoutDoc: Doc;
axes: string[];
+ titleCol: string;
records: { [key: string]: any }[];
width: number;
height: number;
@@ -63,17 +64,17 @@ export class Histogram extends ObservableReactComponent<HistogramProps> {
if (this._props.axes.length < 1) return [];
if (this._props.axes.length < 2) {
var ax0 = this._props.axes[0];
- if (/\d/.test(this._props.records[0][ax0])) {
+ if (!/[A-Za-z-:]/.test(this._props.records[0][ax0])){
this.numericalXData = true;
}
return this._tableData.map(record => ({ [ax0]: record[this._props.axes[0]] }));
}
var ax0 = this._props.axes[0];
var ax1 = this._props.axes[1];
- if (/\d/.test(this._props.records[0][ax0])) {
+ if (!/[A-Za-z-:]/.test(this._props.records[0][ax0])) {
this.numericalXData = true;
}
- if (/\d/.test(this._props.records[0][ax1])) {
+ if (!/[A-Za-z-:]/.test(this._props.records[0][ax1])) {
this.numericalYData = true;
}
return this._tableData.map(record => ({ [ax0]: record[this._props.axes[0]], [ax1]: record[this._props.axes[1]] }));
@@ -89,9 +90,6 @@ export class Histogram extends ObservableReactComponent<HistogramProps> {
@computed get parentViz() {
return DocCast(this._props.Document.dataViz_parentViz);
- // return LinkManager.Instance.getAllRelatedLinks(this._props.Document) // out of all links
- // .filter(link => link.link_anchor_1 == this._props.Document.dataViz_parentViz) // get links where this chart doc is the target of the link
- // .map(link => DocCast(link.link_anchor_1)); // then return the source of the link
}
@computed get rangeVals(): { xMin?: number; xMax?: number; yMin?: number; yMax?: number } {
@@ -454,6 +452,18 @@ export class Histogram extends ObservableReactComponent<HistogramProps> {
: ''
);
selected = selected.substring(0, selected.length - 2) + ' }';
+ if (this._props.titleCol!="" && (!this._currSelected["frequency"] || this._currSelected["frequency"]<10)){
+ selected+= "\n" + this._props.titleCol + ": "
+ this._tableData.forEach(each => {
+ if (this._currSelected[this._props.axes[0]]==each[this._props.axes[0]]) {
+ if (this._props.axes[1]){
+ if (this._currSelected[this._props.axes[1]]==each[this._props.axes[1]]) selected+= each[this._props.titleCol] + ", ";
+ }
+ else selected+= each[this._props.titleCol] + ", ";
+ }
+ })
+ selected = selected.slice(0,-1).slice(0,-1);
+ }
}
var selectedBarColor;
var barColors = StrListCast(this._props.layoutDoc.histogramBarColors).map(each => each.split('::'));