(ndframe: DataFrame | Series, divId: string, plotConfig: InternalPlotConfigObject, Plotly: any)
| 29 | * @param plotConfig configuration options for making Plots, supports Plotly.js Config and Layout parameters. |
| 30 | */ |
| 31 | export const histPlot = (ndframe: DataFrame | Series, divId: string, plotConfig: InternalPlotConfigObject, Plotly: any) => { |
| 32 | const config = plotConfig["config"] |
| 33 | const layout = plotConfig["layout"] |
| 34 | |
| 35 | if (ndframe instanceof Series) { |
| 36 | let trace: Data = { |
| 37 | x: ndframe.values as any, |
| 38 | type: 'histogram', |
| 39 | }; |
| 40 | |
| 41 | Plotly.newPlot(divId, [trace], layout, config); |
| 42 | |
| 43 | } else { |
| 44 | |
| 45 | if (config["x"] || config["y"]) { |
| 46 | //plot single column specified in either of param [x | y] against index |
| 47 | if (config["x"]) { |
| 48 | throwErrorOnWrongColName(ndframe, config.x); |
| 49 | |
| 50 | const x = ndframe[config.x].values; |
| 51 | |
| 52 | const trace: Data = { |
| 53 | x, |
| 54 | type: 'histogram', |
| 55 | }; |
| 56 | |
| 57 | const _layout = { |
| 58 | xaxis: { |
| 59 | title: config.x, |
| 60 | }, |
| 61 | ...layout, |
| 62 | }; |
| 63 | |
| 64 | Plotly.newPlot(divId, [trace], _layout, config); |
| 65 | } |
| 66 | |
| 67 | if (config["y"]) { |
| 68 | throwErrorOnWrongColName(ndframe, config.y); |
| 69 | |
| 70 | const y = ndframe[config.y].values; |
| 71 | |
| 72 | const trace: Data = { |
| 73 | y, |
| 74 | type: 'histogram', |
| 75 | }; |
| 76 | const _layout = { |
| 77 | yaxis: { |
| 78 | title: config.y, |
| 79 | }, |
| 80 | ...layout, |
| 81 | }; |
| 82 | |
| 83 | Plotly.newPlot(divId, [trace], _layout, config); |
| 84 | } |
| 85 | |
| 86 | } else { |
| 87 | //plot specified columns in config param against index |
| 88 | // if columns is not specified in config, then plot all columns |
no test coverage detected