如何在WPF中按代码将Point添加到ChartControl
XAML代码
<Grid>
<dxc:ChartControl>
<dxc:ChartControl.Legends>
<dxc:Legend/>
</dxc:ChartControl.Legends>
<dxc:XYDiagram2D>
<dxc:BarSideBySideSeries2D DisplayName="Series 1"/>
</dxc:XYDiagram2D>
</dxc:ChartControl>
</Grid>
答案 0 :(得分:0)
您可以add points to a series manually:
public static function send_cust_vend_notification($order_id, $status) {
if( !in_array( $status, self::ordersms_woocommerce_get_option( 'ordersms_woocommerce_send_sms', 'customer_setting', array() ) ) ) return;
$log = new Ordersms_WooCoommerce_Logger();
$order_details = new WC_Order($order_id);
//vendors and items been bought
$vendors = array();
$items = $order_details->get_items();
foreach ($items as $item) {
$prodid = $item['product_id'];
$vends = get_the_terms($prodid, 'dc_vendor_shop');
foreach ($vends as $vend) {
if (!in_array($vend, $vendors)) {
array_push($vendors, $vend);
}
}
}
$vids = array();
foreach ($vendors as $vend) {
$terms = get_terms( 'dc_vendor_shop', array(
'term_id' => $vend,
) );
foreach ($terms as $term) {
$vdetails = get_user_by('slug', $term->slug);
$vid = $vdetails->ID;
if (!in_array($vid, $vids)) {
array_push($vids, $vid);
}
}
}
$buyer_firstname = $order->billing_first_name;
$buyer_lastname = $order->billing_last_name;
$buyer_email = $order->billing_email;
$buyer_phone = $order->billing_phone;
$ordertotal = $order->order_total;
$vphone = '';
foreach ($vids as $v)
{
// send sms to vendors
$vphone = get_user_meta($v, 'billing_phone', true);
}
for ($v = 0; $v < sizeof($vids); $v++) {
$u = $v + 1;
// send sms to vendors
$sfn = get_user_meta($vids[$v], 'first_name', true);
$sln = get_user_meta($vids[$v], 'last_name', true);
$semail = get_user_meta($vids[$v], 'email', true);
$sphone = get_user_meta($vids[$v], 'billing_phone', true);
$smessage ="Order has been placed. Please verify";
self::send_sms($sphone, $smessage);
}
$message = self::ordersms_woocommerce_get_option('ordersms_woocommerce_sms_template_'.$status, 'customer_setting', '');
if (empty($message)) {
$message = self::ordersms_woocommerce_get_option('ordersms_woocommerce_sms_template_default', 'customer_setting', '');
}
if (empty($message)) {
return;
}
$message = self::replace_order_keyword($message, $order_details, 'customer', $status);
require_once plugin_dir_path(dirname(__FILE__)). 'lib/autoload.php';
try{
$phoneNumberUtil = \libphonenumber\PhoneNumberUtil::getInstance();
$phoneNumber = $phoneNumberUtil->parse($order_details->get_billing_phone(), $order_details->get_billing_country());
if($phoneNumberUtil->isValidNumber($phoneNumber) && $phoneNumberUtil->getNumberType($phoneNumber) == 1) {
$customer_phone_no = $phoneNumberUtil->format($phoneNumber, \libphonenumber\PhoneNumberFormat::E164);
$customer_phone_no = self::phone_number_processing($customer_phone_no);
$log->add('OrderSMS', 'Customer\'s billing phone number ('.$order_details->get_billing_phone().') in country ('.$order_details->get_billing_country().') converted to '.$customer_phone_no);
self::send_sms($customer_phone_no, $message);
} else {
$log->add('OrderSMS', 'Customer\'s billing phone number ('.$order_details->get_billing_phone().') not a valid mobile number in country ('.$order_details->get_billing_country().'), not sending SMS.');
}
}
catch (Exception $e) {
$log->add('OrderSMS', 'Unable to retrieve customer\'s billing phone number ('.$order_details->get_billing_phone().') or country ('.$order_details->get_billing_country().').');
$log->add('OrderSMS', 'Error ' . $e->getMessage());
}
}
Here是完整的示例。
有关更多信息,请查看Providing Data帮助文章。
答案 1 :(得分:0)
尝试从后面的代码中将SeriesPoint
添加到Points
集合中。就像
barSeries.Points.Add(new DevExpress.Xpf.Charts.SeriesPoint { Argument = "A", Value = 1 });
barSeries.Points.Add(new DevExpress.Xpf.Charts.SeriesPoint { Argument = "B", Value = 2 });
barSeries.Points.Add(new DevExpress.Xpf.Charts.SeriesPoint { Argument = "C", Value = 3 });
barSeries
是您的BarSideBySideSeries2D
系列。