def chart_function_bars(): df = results.get_scalars("name =~ rxBytes:sum OR name =~ txBytes:sum", include_runattrs=True) names = utils.get_names_for_title(df, dict()) df = pd.pivot_table(df, index="name", columns="module", values='value') utils.preconfigure_plot(dict()) utils.plot_bars(df, dict(), names) utils.postconfigure_plot(dict())
utils.preconfigure_plot(props) # collect parameters for query filter_expression = props["filter"] include_fields = props["include_fields"] == "true" # query scalar data into dataframe try: df = results.get_scalars(filter_expression, include_fields=include_fields, include_attrs=True, include_runattrs=True, include_itervars=True) except results.ResultQueryError as e: raise chart.ChartScriptError("Error while querying results: " + str(e)) if df.empty: raise chart.ChartScriptError("The result filter returned no data.") groups, series = utils.select_groups_series(df, props) confidence_level = utils.get_confidence_level(props) valuedf, errorsdf, metadf = utils.pivot_for_barchart(df, groups, series, confidence_level) utils.plot_bars(valuedf, errorsdf, metadf, props) utils.postconfigure_plot(props) utils.export_image_if_needed(props) utils.export_data_if_needed(df, props)
utils.assert_columns_exist(df, groups + series, "No such iteration variable or run attribute") for c in groups + series: df[c] = pd.to_numeric(df[c], errors="ignore") # names for title, confidence level names = ", ".join(utils.get_names_for_title(df, props)) confidence_level_str = props[ "confidence_level"] if "confidence_level" in props else "none" # pivoting and plotting df.sort_values(by=groups + series, axis='index', inplace=True) if confidence_level_str == "none": df = pd.pivot_table(df, index=groups, columns=series, values='value') utils.plot_bars(df, props, names) else: confidence_level = float(confidence_level_str[:-1]) / 100 def conf_intv(values): return utils.confidence_interval(confidence_level, values) df = pd.pivot_table(df, index=groups, columns=series, values='value', aggfunc=[np.mean, conf_intv], dropna=False) utils.plot_bars(df["mean"], props, names, df["conf_intv"]) utils.postconfigure_plot(props)
utils.assert_columns_exist(df, groups + series, "No such iteration variable or run attribute") for c in groups + series: df[c] = pd.to_numeric(df[c], errors="ignore") df.sort_values(by=groups + series, axis='index', inplace=True) names = utils.get_names_for_title(df, props) confidence_level_str = props[ "confidence_level"] if "confidence_level" in props else "none" if confidence_level_str == "none": df = pd.pivot_table(df, index=groups, columns=series, values='value') utils.plot_bars(df, props, names) else: confidence_level = float(confidence_level_str[:-1]) / 100 conf_int = lambda values: utils.confidence_interval( confidence_level, values) if len(values) > 1 else math.nan df = pd.pivot_table(df, index=groups, columns=series, values='value', aggfunc=[np.mean, conf_int], dropna=False) utils.plot_bars(df["mean"], props, names, df["<lambda>"]) utils.postconfigure_plot(props) utils.export_image_if_needed(props)
series = props["series"].split(",") if not groups[0] and not series[0]: print( "The Groups and Series options were not set in the dialog, inferring them from the data." ) g, s = ("module", "name") if len(df) == 1 else utils.pick_two_columns(df) if not g or not s: plot.set_warning( "Please set the Groups and Series options in the dialog!") exit(1) groups, series = [g], [s] utils.assert_columns_exist(df, groups + series) for c in groups + series: df[c] = pd.to_numeric(df[c], errors="ignore") df.sort_values(by=groups + series, axis='index', inplace=True) names = utils.get_names_for_title(df, props) df = pd.pivot_table(df, index=groups, columns=series, values='value') utils.plot_bars(df, props, names) utils.postconfigure_plot(props) utils.export_image_if_needed(props) utils.export_data_if_needed(df, props)