我想从资金中绘制数据,但是当我将它们添加到wpftoolkit图表时,它会添加一个偏移量,大约+5。这导致图形被绘制在图表区域之外。数据上的最大值为259,66,但正如您在图表中可以看到的那样265以上:
以下是xaml中的代码:
import QtQuick 2.4
import QtQuick.Controls 1.3
import QtQuick.Window 2.2
ApplicationWindow {
title: qsTr("Hello World")
width: 640
height: 480
visible: true
Rectangle {
id: checkboxContainer
anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
height: 100
color: "pink"
CheckBox {
id: menuCheckBox
anchors.centerIn: parent
text: qsTr("Click Me")
}
}
Rectangle {
id: menu
anchors.top: checkboxContainer.bottom
anchors.left: parent.left
anchors.right: parent.right
height: 0 //This is the default value when the 'default' state is active. That is whenever we're not in the "openState"
clip: true // this hurts rendering performance a bit but is required to make sure child elements don't exceed the bounderies of this object (so when height is zero you don't see the text)
color: "lightblue"
states: [
State {
name: "openState"
when: menuCheckBox.checked // This state is only active when the check box is checked. When you uncheck the check box we move to the 'default' state (which sets the menu's hight back to zero)
PropertyChanges {
target: menu
height: 100
}
}
]
transitions: Transition {
NumberAnimation {
property: "height"
duration: 350 //This means when the height property is changed it will take 350ms to move from what its at to what your changing it to (i.e. 0 to 100 or 100 to 0).
easing.type: Easing.InOutQuad
}
}
Text {
anchors.centerIn: parent
color: "red"
antialiasing: true
smooth: true
text: qsTr("HELLO")
}
}
}
将数据添加到图表中:
<DVC:Chart Grid.Column="1" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Canvas.Top="80" Canvas.Left="10" Name="Chart">
<DVC:Chart.Series>
<DVC:LineSeries Title="" IndependentValueBinding="{Binding Path=Key}" DependentValueBinding="{Binding Path=Value}" Margin="0,-34,-14,-22">
</DVC:LineSeries>
</DVC:Chart.Series>
</DVC:Chart>
这就是我将字符串转换为double的方式:
public IDictionary<DateTime, double> values { get; set; }
private void LoadLineChartData(Fund fund)
{
((LineSeries)Chart.Series[0]).ItemsSource = fund.values;
}
答案 0 :(得分:0)
找到解决方案。 它的边缘/填充会使事情变得混乱。