mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
The following issues were fixed in Graph Visualiser:
1) Allow the user to set the row limit and chart line width. 2) Zoom should only be applied to X-axis, not both. 3) On clicking the 'Generate' button, the chart should return to its original zoom level. 4) Negative values are not displayed. refs #7485
This commit is contained in:
@@ -1089,11 +1089,11 @@ def fetch(trans_id, fetch_all=None):
|
||||
|
||||
|
||||
@blueprint.route(
|
||||
'/fetch_all_from_start/<int:trans_id>', methods=["GET"],
|
||||
'/fetch_all_from_start/<int:trans_id>/<int:limit>', methods=["GET"],
|
||||
endpoint='fetch_all_from_start'
|
||||
)
|
||||
@login_required
|
||||
def fetch_all_from_start(trans_id):
|
||||
def fetch_all_from_start(trans_id, limit=-1):
|
||||
"""
|
||||
This function is used to fetch all the records from start and reset
|
||||
the cursor back to it's previous position.
|
||||
@@ -1111,7 +1111,7 @@ def fetch_all_from_start(trans_id):
|
||||
# Reset the cursor to start to fetch all the records.
|
||||
conn.reset_cursor_at(0)
|
||||
|
||||
status, result = conn.async_fetchmany_2darray(-1)
|
||||
status, result = conn.async_fetchmany_2darray(limit)
|
||||
if not status:
|
||||
status = 'Error'
|
||||
else:
|
||||
|
||||
@@ -69,6 +69,7 @@ function GenerateGraph({graphType, graphData, ...props}) {
|
||||
let showDataPoints = queryToolCtx.preferences.graphs['graph_data_points'];
|
||||
let useDiffPointStyle = queryToolCtx.preferences.graphs['use_diff_point_style'];
|
||||
let showToolTip = queryToolCtx.preferences.graphs['graph_mouse_track'];
|
||||
let lineBorderWidth = queryToolCtx.preferences.graphs['graph_line_border_width'];
|
||||
|
||||
// Below options are used by chartjs while rendering the graph
|
||||
const options = useMemo(()=>({
|
||||
@@ -76,6 +77,9 @@ function GenerateGraph({graphType, graphData, ...props}) {
|
||||
point: {
|
||||
radius: showDataPoints ? DATA_POINT_SIZE : 0,
|
||||
},
|
||||
line: {
|
||||
borderWidth: lineBorderWidth,
|
||||
},
|
||||
},
|
||||
plugins: {
|
||||
legend: {
|
||||
@@ -100,7 +104,7 @@ function GenerateGraph({graphType, graphData, ...props}) {
|
||||
borderWidth: 1,
|
||||
backgroundColor: 'rgba(54, 162, 235, 0.3)'
|
||||
},
|
||||
mode: 'xy',
|
||||
mode: 'x',
|
||||
},
|
||||
}
|
||||
},
|
||||
@@ -249,12 +253,16 @@ export function GraphVisualiser({initColumns}) {
|
||||
const onGenerate = async ()=>{
|
||||
setLoaderText(gettext('Fetching all the records...'));
|
||||
|
||||
onResetZoom();
|
||||
|
||||
let url = url_for('sqleditor.fetch_all_from_start', {
|
||||
'trans_id': queryToolCtx.params.trans_id
|
||||
'trans_id': queryToolCtx.params.trans_id,
|
||||
'limit': queryToolCtx.preferences.sqleditor.row_limit
|
||||
});
|
||||
|
||||
let res = await queryToolCtx.api.get(url);
|
||||
|
||||
setLoaderText(gettext('Rendering data points...'));
|
||||
// Set the Graph Data
|
||||
setGraphData(
|
||||
getGraphDataSet(res.data.data.result, columns, xaxis, yaxis, queryToolCtx)
|
||||
@@ -265,7 +273,7 @@ export function GraphVisualiser({initColumns}) {
|
||||
|
||||
// Reset the zoom to normal
|
||||
const onResetZoom = ()=> {
|
||||
chartObjRef.current.resetZoom();
|
||||
chartObjRef?.current?.resetZoom();
|
||||
};
|
||||
|
||||
// Download button callback
|
||||
|
||||
@@ -12,7 +12,7 @@ from flask_babel import gettext
|
||||
from pgadmin.utils.constants import PREF_LABEL_DISPLAY,\
|
||||
PREF_LABEL_KEYBOARD_SHORTCUTS, PREF_LABEL_EXPLAIN, PREF_LABEL_OPTIONS,\
|
||||
PREF_LABEL_EDITOR, PREF_LABEL_CSV_TXT, PREF_LABEL_RESULTS_GRID,\
|
||||
PREF_LABEL_SQL_FORMATTING
|
||||
PREF_LABEL_SQL_FORMATTING, PREF_LABEL_GRAPH_VISUALISER
|
||||
from pgadmin.utils import SHORTCUT_FIELDS as shortcut_fields, \
|
||||
ACCESSKEY_FIELDS as accesskey_fields
|
||||
|
||||
@@ -806,3 +806,13 @@ def register_query_tool_preferences(self):
|
||||
'when the tab key or auto-indent are used.'
|
||||
)
|
||||
)
|
||||
|
||||
self.row_limit = self.preference.register(
|
||||
'graph_visualiser', 'row_limit',
|
||||
gettext("Row Limit"), 'integer',
|
||||
10000, min_val=1, category_label=PREF_LABEL_GRAPH_VISUALISER,
|
||||
help_str=gettext('This setting specifies the maximum number of rows '
|
||||
'that will be plotted on a chart. Increasing this '
|
||||
'limit may impact performance if charts are plotted '
|
||||
'with very high numbers of rows.')
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user