Hello,
Let's say my horizontal axis is a datetime axis. If I have one column in every 10th minute the columns are thick. When I have one column in every minute the columns are thin.
I would want to set a static width for every column (let's say 10 pixel) and even if two columns would be too close to each other they could just overlap. Is that possible?
Thanks in advance!
Best regards,
Tamas.
|
<syncfusion:SfChart.Resources>
<ResourceDictionary>
<DataTemplate x:Key="seriesTemplate">
<Canvas>
<Border Background="{Binding Interior}"
Canvas.Left="{Binding RectX}"
Canvas.Top="{Binding RectY}"
Width="10"
Height="{Binding Height}" />
</Canvas>
</DataTemplate>
</ResourceDictionary>
</syncfusion:SfChart.Resources>
<syncfusion:ColumnSeries x:Name="columnSeries"
YBindingPath="Value"
XBindingPath="XValue"
ItemsSource="{Binding Data1}"
CustomTemplate="{StaticResource seriesTemplate}">
</syncfusion:ColumnSeries> |
Hi Yuvaraj Palanisamy,
Thank you, now the fixed width is working very well!
Sadly, now I have another issue. The chart is loading live data of the last one hour and if the chart contains only one element, the column is not visible, only after I add a second column to the chart.
The only thing I found is that if I change the Canvas.Left property of the custom template to 0 the column turns visible.
<Border Background="{Binding Interior}"
Canvas.Left="{Binding RectX}"
Canvas.Top="{Binding RectY}"
Width="12"
Height="{Binding Height}" />Only one record:
Three records: (same result with two records)
And after I change the Canvas.Left property:
<Border Background="{Binding Interior}"
Canvas.Left="0"
Canvas.Top="{Binding RectY}"
Width="12"
Height="{Binding Height}" />
Please help me solve this issue.
Thanks in advance!
Best regards,
Tamas
Hello Yuvaraj Palanisamy,
This is the xaml code of the chart that is shown on the pictures I attached earlier.
<sync:SfChart Height="163"
Margin="0,0,2,0">
<sync:SfChart.Resources>
<ResourceDictionary>
<DataTemplate x:Key="seriesTemplate">
<Canvas>
<Border Background="{Binding Interior}"
Canvas.Left="{Binding RectX}"
Canvas.Top="{Binding RectY}"
Width="8"
Height="{Binding Height}" />
</Canvas>
</DataTemplate>
</ResourceDictionary>
</sync:SfChart.Resources>
<sync:SfChart.PrimaryAxis>
<sync:DateTimeAxis Minimum="{Binding Start, UpdateSourceTrigger=PropertyChanged}"
Maximum="{Binding End, UpdateSourceTrigger=PropertyChanged}"
Interval="1"
Visibility="Visible"
LabelFormat="HH:mm" />
</sync:SfChart.PrimaryAxis>
<sync:SfChart.SecondaryAxis>
<sync:NumericalAxis Maximum="150"
Interval="50" />
</sync:SfChart.SecondaryAxis>
<sync:SfChart.Series>
<sync:StackingColumnSeries ShowTooltip="True"
SegmentColorPath="CycleTimeColor"
ItemsSource="{Binding HourlyData}"
XBindingPath="Date"
CustomTemplate="{StaticResource seriesTemplate}"
YBindingPath="Interval1" />
<sync:StackingColumnSeries ShowTooltip="True"
SegmentColorPath="IntervalColor"
ItemsSource="{Binding HourlyData}"
CustomTemplate="{StaticResource seriesTemplate}"
Label="Interval2"
XBindingPath="Date"
YBindingPath="Interval2" />
</sync:SfChart.Series>
</sync:SfChart>
Thanks in advance!
Best regards,
Tamas
Hello Yuvaraj Palanisamy,
Thank you very much, I will track the private request then.
I marked your first reply to my original question as answer.
Best regards,
Tamas.
|
<DataTemplate x:Key="seriesTemplate">
<Canvas>
<Border Background="{Binding Interior}"
Canvas.Left="{Binding Converter={StaticResource segmentConverter}}"
Canvas.Top="{Binding RectY}"
Width="12"
Height="{Binding Height}" />
</Canvas>
</DataTemplate> |
|
public class SegmentValueConverter : System.Windows.Data.IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
var segment = value as Syncfusion.UI.Xaml.Charts.ColumnSegment;
var center = segment.RectX + (segment.Width) / 2 - (segment.Series as CustomColumnSeries).FixedPixelWidth / 2;
return center;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
} |