Chart Select cümlesi ve diğer özellikler eklendi.

This commit is contained in:
Sedat Öztürk 2025-09-28 23:22:18 +03:00
parent 531b924f5e
commit 565357ba3e
19 changed files with 317 additions and 158 deletions

View file

@ -89,6 +89,8 @@ public class SelectRequestDto
/// <summary> Grid uzerinde kullanici tarafli bir degisiklik var mi
/// </summary>
/// <returns></returns>
public bool Chart { get; set; } = false;
public bool IsChanged()
{
if (!Sort.IsNullOrEmpty() ||

View file

@ -88,16 +88,16 @@ public class ListFormJsonRowAppService : PlatformAppService
listForm.ExtraFilterJson = CreateRow(listForm.ExtraFilterJson, ObjectMapper.Map<ExtraFilterEditDto, ExtraFilter>(model.ItemExtraFilter));
break;
case ListFormEditTabs.ChartSeries.GeneralJsonRow:
listForm.SeriesJson = CreateRow(listForm.SeriesJson, ObjectMapper.Map<ChartSeriesDto, ChartSeries>(model.ItemChartSeries));
listForm.SeriesJson = CreateRow<ChartSeriesDto>(listForm.SeriesJson, model.ItemChartSeries);
break;
case ListFormEditTabs.ChartAxis.ValueAxisJsonRow:
listForm.ValueAxisJson = CreateRow(listForm.ValueAxisJson, ObjectMapper.Map<ChartValueAxisDto, ChartValueAxis>(model.ItemChartValueAxis));
listForm.ValueAxisJson = CreateRow<ChartValueAxisDto>(listForm.ValueAxisJson, model.ItemChartValueAxis);
break;
case ListFormEditTabs.ChartPanes.PanesJsonRow:
listForm.PanesJson = CreateRow(listForm.PanesJson, ObjectMapper.Map<ChartPanesDto, ChartPanes>(model.ItemChartPanes));
listForm.PanesJson = CreateRow<ChartPanesDto>(listForm.PanesJson, model.ItemChartPanes);
break;
case ListFormEditTabs.ChartAnnotations.GeneralJsonRow:
listForm.AnnotationsJson = CreateRow(listForm.AnnotationsJson, ObjectMapper.Map<ChartAnnotationDto, ChartAnnotation>(model.ItemChartAnnotation));
listForm.AnnotationsJson = CreateRow<ChartAnnotationDto>(listForm.AnnotationsJson, model.ItemChartAnnotation);
break;
default:
throw new UserFriendlyException(L[AppErrorCodes.ParameterNotValid]);
@ -142,16 +142,16 @@ public class ListFormJsonRowAppService : PlatformAppService
listForm.ExtraFilterJson = UpdateRow(listForm.ExtraFilterJson, ObjectMapper.Map<ExtraFilterEditDto, ExtraFilter>(model.ItemExtraFilter), model.Index);
break;
case ListFormEditTabs.ChartSeries.GeneralJsonRow:
listForm.SeriesJson = UpdateRow(listForm.SeriesJson, ObjectMapper.Map<ChartSeriesDto, ChartSeries>(model.ItemChartSeries), model.Index);
listForm.SeriesJson = UpdateRow<ChartSeriesDto>(listForm.SeriesJson, model.ItemChartSeries, model.Index);
break;
case ListFormEditTabs.ChartAxis.ValueAxisJsonRow:
listForm.ValueAxisJson = UpdateRow(listForm.ValueAxisJson, ObjectMapper.Map<ChartValueAxisDto, ChartValueAxis>(model.ItemChartValueAxis), model.Index);
listForm.ValueAxisJson = UpdateRow<ChartValueAxisDto>(listForm.ValueAxisJson, model.ItemChartValueAxis, model.Index);
break;
case ListFormEditTabs.ChartPanes.PanesJsonRow:
listForm.PanesJson = UpdateRow(listForm.PanesJson, ObjectMapper.Map<ChartPanesDto, ChartPanes>(model.ItemChartPanes), model.Index);
listForm.PanesJson = UpdateRow<ChartPanesDto>(listForm.PanesJson, model.ItemChartPanes, model.Index);
break;
case ListFormEditTabs.ChartAnnotations.GeneralJsonRow:
listForm.AnnotationsJson = UpdateRow(listForm.AnnotationsJson, ObjectMapper.Map<ChartAnnotationDto, ChartAnnotation>(model.ItemChartAnnotation), model.Index);
listForm.AnnotationsJson = UpdateRow<ChartAnnotationDto>(listForm.AnnotationsJson, model.ItemChartAnnotation, model.Index);
break;
default:
throw new UserFriendlyException(L[AppErrorCodes.ParameterNotValid]);
@ -232,6 +232,7 @@ public class ListFormJsonRowAppService : PlatformAppService
JsonSerializer.Deserialize<List<T>>(json);
listData.Add(input);
return JsonSerializer.Serialize(listData);
}
private string UpdateRow<T>(string json, T input, int index)

View file

@ -183,6 +183,10 @@ public class ListFormSelectAppService : PlatformAppService, IListFormSelectAppSe
{
result.TotalCount = await dynamicDataRepository.ExecuteScalarAsync<int>(selectQueryManager.TotalCountQuery, connectionString, param);
}
else if(queryParams.Chart && !string.IsNullOrEmpty(selectQueryManager.ChartQuery))
{
result.Data = await dynamicDataRepository.QueryAsync(selectQueryManager.ChartQuery, connectionString, param);
}
else
{
result.Data = await dynamicDataRepository.QueryAsync(selectQueryManager.SelectQuery, connectionString, param);

View file

@ -9,13 +9,15 @@ namespace Kurs.Platform.Queries;
/// </summary>
public class Break : ValueObject
{
[JsonInclude]
[JsonPropertyName("StartValue")]
public int StartValue { get; private set; }
[JsonInclude]
[JsonPropertyName("EndValue")]
public int EndValue { get; private set; }
protected Break() { } // Json buradan set edecek
public Break() { } // JSON için gerekli
protected override IEnumerable<object> GetAtomicValues()
{

View file

@ -4,21 +4,22 @@ using Volo.Abp.Domain.Values;
namespace Kurs.Platform.Queries;
/// <summary>
/// Break style tanımı
/// </summary>
public class BreakStyle : ValueObject
{
[JsonInclude]
[JsonPropertyName("Color")]
public string Color { get; private set; }
[JsonInclude]
[JsonPropertyName("Line")]
public string Line { get; private set; }
[JsonInclude]
[JsonPropertyName("Width")]
public int Width { get; private set; }
protected BreakStyle() { }
// JSON deserialization için parametresiz public ctor bırak
public BreakStyle() { }
protected override IEnumerable<object> GetAtomicValues()
{

View file

@ -1,31 +1,34 @@
using System.Collections.Generic;
using System.Text.Json.Serialization;
using Volo.Abp.Domain.Values;
namespace Kurs.Platform.Queries;
public class ChartAnnotation : ValueObject
{
public string Argument { get; private set; }
public ChartBorder Border { get; private set; }
public string Color { get; private set; } = "#ffffff";
public string Description { get; private set; }
public ChartFont Font { get; private set; }
public int Height { get; private set; } = -1;
public string Image { get; private set; }
public string Name { get; private set; }
public int OffsetX { get; private set; } = -1;
public int OffsetY { get; private set; } = -1;
public int PaddingLeftRight { get; private set; } = 10;
public int PaddingTopBottom { get; private set; } = 10;
public string Series { get; private set; }
public string Text { get; private set; }
public bool TooltipEnabled { get; private set; } = true;
public string Type { get; private set; }
public string Value { get; private set; }
public int Width { get; private set; }
public string WordWrap { get; private set; } = "normal";
public int X { get; private set; }
public int Y { get; private set; }
[JsonInclude] public string Argument { get; private set; }
[JsonInclude] public ChartBorder Border { get; private set; } = new();
[JsonInclude] public string Color { get; private set; } = "#ffffff";
[JsonInclude] public string Description { get; private set; }
[JsonInclude] public ChartFont Font { get; private set; } = new();
[JsonInclude] public int Height { get; private set; } = -1;
[JsonInclude] public string Image { get; private set; }
[JsonInclude] public string Name { get; private set; }
[JsonInclude] public int OffsetX { get; private set; } = -1;
[JsonInclude] public int OffsetY { get; private set; } = -1;
[JsonInclude] public int PaddingLeftRight { get; private set; } = 10;
[JsonInclude] public int PaddingTopBottom { get; private set; } = 10;
[JsonInclude] public string Series { get; private set; }
[JsonInclude] public string Text { get; private set; }
[JsonInclude] public bool TooltipEnabled { get; private set; } = true;
[JsonInclude] public string Type { get; private set; }
[JsonInclude] public string Value { get; private set; }
[JsonInclude] public int Width { get; private set; }
[JsonInclude] public string WordWrap { get; private set; } = "normal";
[JsonInclude] public int X { get; private set; }
[JsonInclude] public int Y { get; private set; }
public ChartAnnotation() { }
protected override IEnumerable<object> GetAtomicValues()
{
@ -52,4 +55,3 @@ public class ChartAnnotation : ValueObject
yield return Y;
}
}

View file

@ -9,16 +9,19 @@ namespace Kurs.Platform.Queries;
/// </summary>
public class ChartAxisGrid : ValueObject
{
[JsonInclude]
[JsonPropertyName("Color")]
public string Color { get; private set; }
[JsonInclude]
[JsonPropertyName("Visible")]
public bool Visible { get; private set; }
[JsonInclude]
[JsonPropertyName("Width")]
public int Width { get; private set; }
protected ChartAxisGrid() { }
public ChartAxisGrid() { } // JSON için gerekli
protected override IEnumerable<object> GetAtomicValues()
{
@ -27,3 +30,4 @@ public class ChartAxisGrid : ValueObject
yield return Width;
}
}

View file

@ -1,16 +1,28 @@
using System.Collections.Generic;
using System.Text.Json.Serialization;
using Volo.Abp.Domain.Values;
namespace Kurs.Platform.Queries;
public class ChartBorder : ValueObject
{
[JsonInclude]
public string Color { get; private set; } = "#d3d3d3";
[JsonInclude]
public int CornerRadius { get; private set; } = 0;
[JsonInclude]
public string DashStyle { get; private set; } = "solid";
[JsonInclude]
public bool Visible { get; private set; }
[JsonInclude]
public int Width { get; private set; } = 1;
public ChartBorder() { } // JSON deserialize için parametresiz public ctor
protected override IEnumerable<object> GetAtomicValues()
{
yield return Color;

View file

@ -1,17 +1,24 @@
using System.Collections.Generic;
using System.Text.Json.Serialization;
using Volo.Abp.Domain.Values;
namespace Kurs.Platform.Queries;
public class ChartFont : ValueObject
{
[JsonInclude]
public string Color { get; private set; } = "#FFFFFF";
[JsonInclude]
public string Family { get; private set; } = "\"Segoe UI\", \"Helvetica Neue\", \"Trebuchet MS\", Verdana, sans-serif";
[JsonInclude]
public int Size { get; private set; } = 12;
[JsonInclude]
public int Weight { get; private set; } = 400;
// EF Core + JSON için korumalı ctor
protected ChartFont() { }
public ChartFont() { }
protected override IEnumerable<object> GetAtomicValues()
{

View file

@ -1,18 +1,18 @@
using System.Collections.Generic;
using System.Text.Json.Serialization;
using Volo.Abp.Domain.Values;
namespace Kurs.Platform.Queries;
public class ChartLabel : ValueObject
{
public string BackgroundColor { get; private set; } = "#f05b41";
public string CustomizeText { get; private set; }
public ChartFont Font { get; private set; }
public bool Visible { get; private set; }
public string Format { get; private set; }
[JsonInclude] public string BackgroundColor { get; private set; } = "#f05b41";
[JsonInclude] public string CustomizeText { get; private set; }
[JsonInclude] public ChartFont Font { get; private set; } = new();
[JsonInclude] public bool Visible { get; private set; }
[JsonInclude] public string Format { get; private set; }
// EF Core + JSON için korumalı ctor
protected ChartLabel() { }
public ChartLabel() { }
protected override IEnumerable<object> GetAtomicValues()
{

View file

@ -6,51 +6,92 @@ namespace Kurs.Platform.Queries;
public class ChartSeries : ValueObject
{
[JsonInclude]
[JsonPropertyName("ArgumentField")]
public string ArgumentField { get; private set; } = "arg";
[JsonInclude]
[JsonPropertyName("Axis")]
public string Axis { get; private set; }
[JsonInclude]
[JsonPropertyName("BarOverlapGroup")]
public string BarOverlapGroup { get; private set; }
[JsonInclude]
[JsonPropertyName("BarPadding")]
public int BarPadding { get; private set; }
[JsonInclude]
[JsonPropertyName("BarWidth")]
public int BarWidth { get; private set; }
[JsonInclude]
[JsonPropertyName("Color")]
public string Color { get; private set; }
[JsonInclude]
[JsonPropertyName("CornerRadius")]
public int CornerRadius { get; private set; } = 0;
[JsonInclude]
[JsonPropertyName("DashStyle")]
public string DashStyle { get; private set; } = "solid";
[JsonInclude]
[JsonPropertyName("IgnoreEmptyPoints")]
public bool IgnoreEmptyPoints { get; private set; } = false;
[JsonInclude]
[JsonPropertyName("Name")]
public string Name { get; private set; }
[JsonInclude]
[JsonPropertyName("Pane")]
public string Pane { get; private set; }
[JsonInclude]
[JsonPropertyName("RangeValue1Field")]
public string RangeValue1Field { get; private set; } = "val1";
[JsonInclude]
[JsonPropertyName("RangeValue2Field")]
public string RangeValue2Field { get; private set; } = "val2";
[JsonInclude]
[JsonPropertyName("SelectionMode")]
public string SelectionMode { get; private set; } = "none";
[JsonInclude]
[JsonPropertyName("ShowInLegend")]
public bool ShowInLegend { get; private set; } = true;
[JsonInclude]
[JsonPropertyName("Type")]
public string Type { get; private set; }
[JsonInclude]
[JsonPropertyName("ValueField")]
public string ValueField { get; private set; }
[JsonInclude]
[JsonPropertyName("SummaryType")]
public string SummaryType { get; private set; }
[JsonInclude]
[JsonPropertyName("Visible")]
public bool Visible { get; private set; } = true;
[JsonInclude]
[JsonPropertyName("Width")]
public int Width { get; private set; } = 2;
[JsonPropertyName("Label")]
public ChartLabel Label { get; private set; }
// EF Core + JSON için korumalı ctor
public ChartSeries() { }
[JsonInclude]
[JsonPropertyName("Label")]
public ChartLabel Label { get; private set; } = new();
// JSON + EF Core için parametresiz public ctor
public ChartSeries() { }
protected override IEnumerable<object> GetAtomicValues()
{
@ -77,4 +118,3 @@ public class ChartSeries : ValueObject
yield return Label;
}
}

View file

@ -7,54 +7,56 @@ namespace Kurs.Platform.Queries;
public class ChartValueAxis : ValueObject
{
[JsonInclude]
[JsonPropertyName("Grid")]
public ChartAxisGrid Grid { get; private set; }
[JsonInclude]
[JsonPropertyName("Name")]
public string Name { get; private set; }
[JsonInclude]
[JsonPropertyName("Position")]
public string Position { get; private set; }
public string Position { get; private set; } = "left";
[JsonInclude]
[JsonPropertyName("Title")]
public string Title { get; private set; }
[JsonInclude]
[JsonPropertyName("ValueType")]
public string ValueType { get; private set; }
public string ValueType { get; private set; } = "numeric";
[JsonInclude]
[JsonPropertyName("Visible")]
public bool Visible { get; private set; }
public bool Visible { get; private set; } = true;
[JsonInclude]
[JsonPropertyName("Width")]
public int Width { get; private set; }
public int Width { get; private set; } = 1;
[JsonInclude]
[JsonPropertyName("Breaks")]
public IReadOnlyCollection<Break> Breaks { get; private set; }
public List<Break> Breaks { get; private set; } = new();
[JsonInclude]
[JsonPropertyName("BreakStyle")]
public BreakStyle BreakStyle { get; private set; }
public BreakStyle BreakStyle { get; private set; } = new();
[JsonInclude]
[JsonPropertyName("Type")]
public string Type { get; private set; }
[JsonInclude]
[JsonPropertyName("AutoBreaksEnabled")]
public bool AutoBreaksEnabled { get; private set; }
public bool AutoBreaksEnabled { get; private set; } = true;
[JsonInclude]
[JsonPropertyName("MaxAutoBreakCount")]
public int MaxAutoBreakCount { get; private set; }
public int MaxAutoBreakCount { get; private set; } = 2;
// 🔑 Bunu bırak yeterli
[JsonConstructor]
protected ChartValueAxis()
{
Breaks = [];
Position = "left";
ValueType = "numeric";
Visible = true;
Width = 1;
AutoBreaksEnabled = true;
MaxAutoBreakCount = 2;
}
protected ChartValueAxis() { }
protected override IEnumerable<object> GetAtomicValues()
{

View file

@ -38,6 +38,9 @@ public class QueryParameters : ValueObject
//select
//userData
//Chart
public bool Chart { get; set; } = false;
protected override IEnumerable<object> GetAtomicValues()
{
yield return ListFormCode;

View file

@ -26,6 +26,7 @@ public interface ISelectQueryManager
Dictionary<string, object> SelectQueryParameters { get; }
string TotalCountQuery { get; }
string GroupQuery { get; }
string ChartQuery { get; }
public string DeleteQuery { get; }
List<(int Index, string Field, string SelectExpr, string Sort, bool IsExpanded, string GroupInterval)> GroupTuples { get; }
List<(int Index, string Field, string SelectExpr, string SummaryType)> GroupSummaryTuples { get; }
@ -98,6 +99,7 @@ public class SelectQueryManager : PlatformDomainService, ISelectQueryManager
public string TotalCountQuery { get; private set; }
public string GroupQuery { get; private set; }
public string DeleteQuery { get; private set; }
public string ChartQuery { get; private set; }
public List<(int Index, string Field, string SelectExpr, string Sort, bool IsExpanded, string GroupInterval)> GroupTuples { get; private set; } = [];
public List<(int Index, string Field, string SelectExpr, string SummaryType)> GroupSummaryTuples { get; private set; } = [];
public List<string> SummaryQueries { get; private set; }
@ -186,6 +188,7 @@ public class SelectQueryManager : PlatformDomainService, ISelectQueryManager
TotalCountQuery = GetTotalCountQuery();
GroupQuery = GetGroupQuery(listFormFields, queryParams);
DeleteQuery = GetDeleteQuery(queryParams);
ChartQuery = GetChartQuery(listform, queryParams);
#region Total Summary Queries
if (queryParams != null && !queryParams.TotalSummary.IsNullOrWhiteSpace())
@ -756,6 +759,58 @@ public class SelectQueryManager : PlatformDomainService, ISelectQueryManager
return $"DELETE \"{TableName}\" FROM {SelectCommand} AS \"{TableName}\" {GetWhereString()}";
}
public string GetChartQuery(ListForm listform, QueryParameters queryParams = null)
{
if (listform == null || string.IsNullOrWhiteSpace(listform.SeriesJson) || queryParams == null)
return null;
var seriesList = JsonSerializer.Deserialize<List<ChartSeries>>(listform.SeriesJson);
if (seriesList == null || !seriesList.Any())
throw new ArgumentException("Series list is empty!");
// ArgumentField listesi
var argumentFields = seriesList.Select(s => s.ArgumentField).Distinct().ToList();
// ArgumentField ifadesini oluştur
string argumentExpression;
if (argumentFields.Count == 1)
{
// Tek ArgumentField
argumentExpression = $"[{argumentFields.First()}]";
}
else
{
// Birden fazla → '|' ile birleştir
argumentExpression = string.Join(" + '|' + ", argumentFields.Select(f => $"[{f}]"));
}
// Select sütunlarını oluştur
var selectParts = new List<string> { $"{argumentExpression} AS ArgumentField" };
foreach (var series in seriesList)
{
string sqlFunc = series.SummaryType.ToUpper() switch
{
"COUNT" => $"COUNT([{series.ValueField}])",
"SUM" => $"SUM([{series.ValueField}])",
"AVG" => $"AVG([{series.ValueField}])",
"MIN" => $"MIN([{series.ValueField}])",
"MAX" => $"MAX([{series.ValueField}])",
_ => throw new NotSupportedException($"Unsupported SummaryType: {series.SummaryType}")
};
selectParts.Add($"{sqlFunc} AS [{series.Name}]");
}
// SQL cümlesi
var sql = $@"
SELECT {string.Join(", ", selectParts)}
FROM [{listform.SelectCommand}]
GROUP BY {argumentExpression}";
return sql;
}
private string GetDefaultValue(string strValue)
{
return strValue?.Replace(PlatformConsts.DefaultValues.UserId, CurrentUser.Id.ToString())

View file

@ -23,8 +23,7 @@ const useListFormCustomDataSource = ({
listFormCode: string,
searchParams?: URLSearchParams,
cols?: GridColumnData[],
group?: string,
groupSummary?: string
chart?: boolean,
) => {
const store: any = new CustomStore({
key: gridOptions.keyFieldName,
@ -34,10 +33,8 @@ const useListFormCustomDataSource = ({
listFormCode,
filter: '',
createDeleteQuery: searchParams?.get('createDeleteQuery'),
group,
groupSummary
chart,
})
// 1. Default filter'ı al
const defaultFilter = searchParams?.get('filter')
? JSON.parse(searchParams.get('filter')!)

View file

@ -289,69 +289,79 @@ function JsonRowOpDialogAxis({
</TabList>
<div className="pt-4">
<TabContent value="grid">
<FormItem
label="Visible"
invalid={errors.grid?.visible && touched.grid?.visible}
errorMessage={errors.grid?.visible}
>
<Field name="grid.visible" component={Checkbox} />
</FormItem>
<div className="grid grid-cols-3 gap-2">
<FormItem
label="Visible"
className="col-span-1"
invalid={errors.grid?.visible && touched.grid?.visible}
errorMessage={errors.grid?.visible}
>
<Field name="grid.visible" component={Checkbox} />
</FormItem>
<FormItem
label="Color"
invalid={errors.grid?.color && touched.grid?.color}
errorMessage={errors.grid?.color}
>
<Field type="text" name="grid.color" component={Input} />
</FormItem>
<FormItem
label="Color"
className="col-span-1"
invalid={errors.grid?.color && touched.grid?.color}
errorMessage={errors.grid?.color}
>
<Field type="text" name="grid.color" component={Input} />
</FormItem>
<FormItem
label="Width"
invalid={errors.grid?.width && touched.grid?.width}
errorMessage={errors.grid?.width}
>
<Field type="number" name="grid.width" component={Input} />
</FormItem>
<FormItem
label="Width"
className="col-span-1"
invalid={errors.grid?.width && touched.grid?.width}
errorMessage={errors.grid?.width}
>
<Field type="number" name="grid.width" component={Input} />
</FormItem>
</div>
</TabContent>
<TabContent value="breakStyle">
<FormItem
label="Color"
invalid={errors.breakStyle?.color && touched.breakStyle?.color}
errorMessage={errors.breakStyle?.color}
>
<Field type="text" name="breakStyle.color" component={Input} />
</FormItem>
<div className="grid grid-cols-4 gap-2">
<FormItem
label="Color"
className="col-span-1"
invalid={errors.breakStyle?.color && touched.breakStyle?.color}
errorMessage={errors.breakStyle?.color}
>
<Field type="text" name="breakStyle.color" component={Input} />
</FormItem>
<FormItem
label="Width"
invalid={errors.breakStyle?.width && touched.breakStyle?.width}
errorMessage={errors.breakStyle?.width}
>
<Field type="number" name="breakStyle.width" component={Input} />
</FormItem>
<FormItem
label="Width"
className="col-span-1"
invalid={errors.breakStyle?.width && touched.breakStyle?.width}
errorMessage={errors.breakStyle?.width}
>
<Field type="number" name="breakStyle.width" component={Input} />
</FormItem>
<FormItem
label="Line"
invalid={errors.breakStyle?.line && touched.breakStyle?.line}
errorMessage={errors.breakStyle?.line}
>
<Field type="text" name="breakStyle.line">
{({ field, form }: FieldProps<IdentityRoleDto>) => (
<Select
field={field}
form={form}
options={chartBreakStyleLineListOptions}
isClearable={true}
value={chartBreakStyleLineListOptions.filter(
(option) => option.value === values.breakStyle.line,
)}
onChange={(option) =>
form.setFieldValue(field.name, option?.value)
}
/>
)}
</Field>
</FormItem>
<FormItem
label="Line"
className="col-span-2"
invalid={errors.breakStyle?.line && touched.breakStyle?.line}
errorMessage={errors.breakStyle?.line}
>
<Field type="text" name="breakStyle.line">
{({ field, form }: FieldProps<IdentityRoleDto>) => (
<Select
field={field}
form={form}
options={chartBreakStyleLineListOptions}
isClearable={true}
value={chartBreakStyleLineListOptions.filter(
(option) => option.value === values.breakStyle.line,
)}
onChange={(option) =>
form.setFieldValue(field.name, option?.value)
}
/>
)}
</Field>
</FormItem>
</div>
</TabContent>
<TabContent value="breaks">
<FieldArray name="breaks">
@ -369,8 +379,8 @@ function JsonRowOpDialogAxis({
)
return (
<div key={index}>
<FormItem layout="inline" label="Start Value">
<div key={index} className="flex gap-2">
<FormItem label="Start Value">
<Field
invalid={startValueFeedBack.invalid}
name={`breaks[${index}].startValue`}
@ -379,7 +389,7 @@ function JsonRowOpDialogAxis({
/>
</FormItem>
<FormItem layout="inline" label="End Value">
<FormItem label="End Value">
<Field
invalid={endValueFeedBack.invalid}
name={`breaks[${index}].endValue`}
@ -391,7 +401,8 @@ function JsonRowOpDialogAxis({
<Button
shape="circle"
type="button"
size="sm"
className="mt-7"
size="xs"
icon={<FaMinus />}
onClick={() => remove(index)}
/>
@ -401,8 +412,8 @@ function JsonRowOpDialogAxis({
: null}
<div>
<Button
size="xs"
type="button"
className="ltr:mr-2 rtl:ml-2"
onClick={() => {
push({
startValue: 0,

View file

@ -13,7 +13,8 @@ import { usePermission } from '@/utils/hooks/usePermission'
import { Button } from '@/components/ui'
import { ROUTES_ENUM } from '@/routes/route.constant'
import { usePWA } from '@/utils/hooks/usePWA'
import { FaInfoCircle } from 'react-icons/fa'
import { FaInfoCircle, FaSyncAlt } from 'react-icons/fa'
import { buildSeriesDto } from './Utils'
interface ChartProps extends CommonProps, Meta {
listFormCode: string
@ -22,6 +23,7 @@ interface ChartProps extends CommonProps, Meta {
level?: number
refreshData?: () => Promise<void>
gridDto?: GridDto
refreshGridDto: () => Promise<void>
}
const Chart = (props: ChartProps) => {
@ -40,18 +42,12 @@ const Chart = (props: ChartProps) => {
useEffect(() => {
if (!gridDto) return
// console.log(
// gridDto.gridOptions?.seriesDto?.map((s) => `${s.argumentField} asc false`).join(', '),
// )
// console.log(gridDto.gridOptions?.seriesDto?.map((s) => `${s.valueField} count`).join(', '))
const dataSource = createSelectDataSource(
gridDto.gridOptions,
listFormCode,
searchParams,
// [],
// gridDto.gridOptions?.seriesDto?.map((s) => `${s.argumentField} asc false`).join(', '),
// gridDto.gridOptions?.seriesDto?.map((s) => `${s.valueField} count`).join(', '),
[],
true,
)
const options = {
@ -83,13 +79,8 @@ const Chart = (props: ChartProps) => {
valueAxis: gridDto.gridOptions.valueAxisDto,
tooltip: gridDto.gridOptions.tooltipDto,
series: gridDto.gridOptions.seriesDto,
// gridDto.gridOptions.seriesDto?.length > 0
// ? gridDto.gridOptions.seriesDto.map((s) => ({
// argumentField: 'key',
// valueField: 'summary',
// }))
// : undefined,
series: buildSeriesDto(gridDto.gridOptions.seriesDto),
panes: gridDto.gridOptions.panesDto?.length > 0 ? gridDto.gridOptions.panesDto : undefined,
commonSeriesSettings: gridDto.gridOptions.commonSeriesSettingsDto,
commonPaneSettings: gridDto.gridOptions.commonPaneSettingsDto,
@ -115,9 +106,20 @@ const Chart = (props: ChartProps) => {
></Helmet>
)}
{_listFormCode && chartOptions && (
<div className="p-1 bg-white dark:bg-neutral-800 dark:border-neutral-700 ">
<div className="flex justify-end items-center">
<div className="p-1 bg-white dark:bg-neutral-800 dark:border-neutral-700 h-full">
<div className="flex justify-end items-center h-full">
<div className="relative pb-1 flex gap-1 border-b-1">
<Button
size="xs"
variant={'default'}
className="text-sm"
onClick={async () => {
await props.refreshGridDto()
}}
title="Reset Grid State"
>
<FaSyncAlt className="w-3 h-3" />
</Button>
{checkPermission(gridDto?.gridOptions.permissionDto.u) && (
<Button
size="xs"

View file

@ -136,7 +136,7 @@ const List = () => {
setViewMode('chart')
setStates({ listFormCode, layout: 'chart' })
}}
title="Pivot Görünümü"
title="Grafik Görünümü"
>
<FaChartArea className="w-4 h-4" />
</Button>
@ -172,6 +172,7 @@ const List = () => {
filter={searchParams.toString()}
isSubForm={true}
gridDto={gridDto}
refreshGridDto={refreshGridDto}
/>
) : null}
</Container>

View file

@ -1,6 +1,7 @@
import { DataType } from 'devextreme/common'
import { PivotGridDataType } from 'devextreme/ui/pivot_grid/data_source'
import { MULTIVALUE_DELIMITER } from '../../constants/app.constant'
import { ChartSeriesDto } from '@/proxy/admin/charts/models'
export interface GridExtraFilterState {
fieldName: string
@ -134,6 +135,7 @@ export function getLoadOptions(loadOptions: any, params: any) {
'searchValue',
'select',
'userData',
'chart',
].forEach(function (i) {
//if (i in loadOptions && isNotEmpty(loadOptions[i])) {
// params[i] = JSON.stringify(loadOptions[i]);
@ -243,3 +245,14 @@ export function setFormEditingExtraItemValues(values: any) {
return values
}
export function buildSeriesDto(seriesList: ChartSeriesDto[]) {
if (!seriesList || seriesList.length === 0) return []
// her seri için dto oluştur
return seriesList.map((s) => ({
...s,
argumentField: 'ArgumentField',
valueField: s.name,
}))
}