MCPcopy Create free account
hub / github.com/IppClub/Dora-SSR / PlotPieChartEx

Function PlotPieChartEx

Source/3rdParty/implot/implot_items.cpp:2924–2960  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2922
2923template <typename T>
2924void PlotPieChartEx(const char* const label_ids[], IndexerIdx<T> indexer, ImPlotPoint center, double radius, double angle0, const ImPlotSpec& spec) {
2925 ImDrawList& draw_list = *GetPlotDrawList();
2926
2927 const bool ignore_hidden = ImHasFlag(spec.Flags, ImPlotPieChartFlags_IgnoreHidden);
2928 const double sum = PieChartSum(indexer, ignore_hidden);
2929 const bool normalize = ImHasFlag(spec.Flags, ImPlotPieChartFlags_Normalize) || sum > 1.0;
2930
2931 double a0 = angle0 * 2 * IM_PI / 360.0;
2932 double a1 = angle0 * 2 * IM_PI / 360.0;
2933 ImPlotPoint Pmin = ImPlotPoint(center.x - radius, center.y - radius);
2934 ImPlotPoint Pmax = ImPlotPoint(center.x + radius, center.y + radius);
2935 for (int i = 0; i < indexer.Count; ++i) {
2936 ImPlotItem* item = GetItem(label_ids[i]);
2937
2938 const double percent = normalize ? (double)indexer[i] / sum : (double)indexer[i];
2939 const bool skip = sum <= 0.0 || (ignore_hidden && item != nullptr && !item->Show);
2940 if (!skip)
2941 a1 = a0 + 2 * IM_PI * percent;
2942
2943 if (BeginItemEx(label_ids[i], FitterRect(Pmin, Pmax), spec)) {
2944 const bool hovered = ImPlot::IsLegendEntryHovered(label_ids[i]) && ImHasFlag(spec.Flags, ImPlotPieChartFlags_Exploding);
2945 if (sum > 0.0) {
2946 ImU32 col = GetCurrentItem()->Color;
2947 if (percent < 0.5) {
2948 RenderPieSlice(draw_list, center, radius, a0, a1, col, spec.Flags, hovered);
2949 }
2950 else {
2951 RenderPieSlice(draw_list, center, radius, a0, a0 + (a1 - a0) * 0.5, col, spec.Flags, hovered);
2952 RenderPieSlice(draw_list, center, radius, a0 + (a1 - a0) * 0.5, a1, col, spec.Flags, hovered);
2953 }
2954 }
2955 EndItem();
2956 }
2957 if (!skip)
2958 a0 = a1;
2959 }
2960}
2961
2962int PieChartFormatter(double value, char* buff, int size, void* data) {
2963 const char* fmt = (const char*)data;

Callers 1

PlotPieChartFunction · 0.85

Calls 10

GetPlotDrawListFunction · 0.85
ImHasFlagFunction · 0.85
PieChartSumFunction · 0.85
GetItemFunction · 0.85
BeginItemExFunction · 0.85
FitterRectClass · 0.85
IsLegendEntryHoveredFunction · 0.85
GetCurrentItemFunction · 0.85
RenderPieSliceFunction · 0.85
EndItemFunction · 0.85

Tested by

no test coverage detected