###Automatically generated###
###Changes will be overwritten###
Charthelper=ConsoleScope['Charthelper']
PPMS_chart_generator=ConsoleScope['PPMS_chart_generator']
#Initialize variables
df_reference={}
df_reference["AxisXLabel"]=""
df_reference["LegendText"]=""
df_reference["XValue"]=""
df_reference["YValue"]=""
df_reference["ZValue"]=""
df_reference["AxisYLabel"]=""
df_reference["YAxisSuffix"]=""
df_reference["XAxisSuffix"]=""
df_reference["Event"]=""
title=""
da_id=""
xaml_colorset=""
xaml_background_brush=""
xaml_dataseries=""
xaml_chart=""
#Execute datafield configuration
exec(df.Customizing.PythonScriptSettings)
#Get charthelper object
ch = Charthelper(df, df_reference, da_id)
#Get value dictionary
value_dict = ch.value_dict
"""Create PPMS_chart_generator instance
para.1 - xaml_chart, no default value
para.2 - xaml_dataseries, no default value
para.3 - xaml_colorset, no default value
para.4 - xaml_background_brush, no default value
para.5 - dict_values: dictionary, default empty dictionary
para.6 - AxesX _label: String, default empty
para.7 - AxesY _label: String, default empty
para.8 - Title: String, default --> AxesX _label + "/" + AxesY _labell """
#Create PPMS Chart
chart_panel = PPMS_chart_generator(xaml_chart, xaml_dataseries, xaml_colorset, xaml_background_brush, dict_values=ch.value_dict, AxesX _label=ch.get_di_title(df_reference["AxisXLabel"]), AxesY _label=ch.get_di_title(df_reference["AxisYLabel"]), Title=title, modlayout=moduleLayout, dict_event=ch.event_dict, suffix_dict=ch.suffix)
#Get PMS Chart panel
ctl = chart_panel.winpanelxaml_chart=""""""
xaml_dataseries=""""""
xaml_colorset=""""""
xaml_background_brush=""""""
#Initialize datarea_id and chart_title -variable
da_id=""
title=df.DataArea.Customizing.Name
"""Define Chart - Properties"""
#Set datafield_id for chart_values
df_reference={}
df_reference["AxisXLabel"]=""
df_reference["LegendText"]=""
df_reference["XValue"]=""
df_reference["YValue"]=""
df_reference["ZValue"]=""
df_reference["AxisYLabel"]=""  xaml_chart  | 
Erstellung des Chart-Objektes | 
 xaml_dataseries  | 
Template zur Erstellung der Datenpaarobjekte. Legt den Chart-Typ fest | 
 xaml_colorset  | 
Setzen der Farbe für ein Datenpaar. Wenn keine Angaben gemacht werden, wird ein Default-Wert genommen. | 
 xaml_background_brush  | 
Setzen der Hintergrundfarbe. Wenn keine Angaben gemacht werden, wird ein Default-Wert genommen. | 
 verbatim>da_id:  | 
Angabe des Datenbereichs, aus dem die Daten bezogen werden. Die Datenbereichs-ID muss mit führender Null angegeben werden. | 
 title:  | 
Angabe des Chart-Titels. | 
 df_reference:  | 
Jeder Chart-Parameter wird durch Angabe der DF-ID mit einem PLANTA-Datenfeld aus dem Quellbereich referenziert. | 
#Set datafield_id for chart_values df_reference["AxisXLabel"]= Angabe der Feldnummer zum Setzen der Beschriftung df_reference["LegendText"]="" df_reference["XValue"]="" df_reference["YValue"]= Angabe der Feldnummer zum Setzen der Werte df_reference["ZValue"]="" df_reference["AxisYLabel"]=""
#Set datafield_id for chart_values df_reference["AxisXLabel"]= Angabe der Feldnummer zum Setzen der X-Achsen Beschriftung df_reference["LegendText"]="" df_reference["XValue"]="" df_reference["YValue"]= Angabe der Feldnummer zum Setzen der Y-Werte df_reference["ZValue"]="" df_reference["AxisYLabel"]=df_reference["YValue"]
#Set datafield_id for chart_values df_reference["AxisXLabel"]= Angabe der Feldnummer zum Setzen der Einheitsbeschriftung df_reference["LegendText"]="" df_reference["XValue"]="" df_reference["YValue"]= Angabe der Feldnummer zum Setzen des Balkenwertes df_reference["ZValue"]="" df_reference["AxisYLabel"]=df_reference["YValue"]
#Set datafield_id for chart_values df_reference["AxisXLabel"]= Angabe der Feldnummer zum Setzen der Einheitsbeschriftung df_reference["LegendText"]= Angabe der Feldnummer zum Setzen der Legendenbeschriftung df_reference["XValue"]="" df_reference["YValue"]= Angabe der Feldnummer zum Setzen des Balkenwertes df_reference["ZValue"]="" df_reference["AxisYLabel"]=df_reference["YValue"]
import clr
import sys
# Debug: results in reloaded module to reflect code changes in MilestoneChart
# sys.modules.Remove("MTA")
# sys.modules.Remove("MTA.milestone_chart")
from System import DateTime
from System.Windows.Forms import *
from System.Windows.Media import Brushes
from MTA.milestone_chart import milestone_chart
from MTA.milestone_dataseries import milestone_dataseries
from MTA.time_interval_enum import time_interval_enum
# Used global variables from DataField-Configurations
# - targetDataAreaId
# - processIdField
# - processCaptionField
# - reportDateField
# - targetDateField
# - milestoneField
# - milestoneFilter
# - chartTitleField
# report date = Berichtszeitpunkt
# target date = Meilensteintermin
exec(df.Customizing.PythonScriptSettings)
# Get DataAreaRecords
targetDataArea=targetDataAreaId
records=[]
roots=list(df.Module.Roots)
for root in roots:
    dataAreas=list(root.DAManager)
    for dataAreaRecord in dataAreas:
        if dataAreaRecord.Customizing.Uid == targetDataArea:
            records.append(dataAreaRecord)
            
seriesList = {}
fields = {}
# Get field associations from data field configuration
fields["ProcessID"] = processIdField
fields["ProcessCaption"] = processCaptionField
fields["Milestone"] = milestoneField
fields["ReportDate"] = reportDateField
fields["TargetDate"] = targetDateField
fields["ChartTitle"] = chartTitleField
# Initialize milestone value filter
criterias = {}
criterias["Milestone"]=[milestoneFilter]
# Extract needed field-values from records
for record in records:
    values = {}   
    areaCU = record.Customizing
    for key in fields.keys():
        fieldCU = areaCU.ChildrenDFC.TryGetValue(fields[key])[1]
        field = record.ChildrenDF.__getitem__(fieldCU)
        value = field.GetValue[str]()
        values[key] = value
    
    # Filter by milestone value
    if values["Milestone"] in criterias["Milestone"]:
        if values["ReportDate"] != None and values["TargetDate"] != None:
            if values["ProcessID"] not in seriesList.keys():            
                seriesList[values["ProcessID"]] = milestone_dataseries()
            # Create Series from values
            series = seriesList[values["ProcessID"]]
            reportDate = DateTime.Parse(values["ReportDate"])
            targetDate = DateTime.Parse(values["TargetDate"])
            series.data_points.Add(reportDate, targetDate)
            if values["ProcessCaption"] != None and values["ProcessCaption"] != "":
                series.title = values["ProcessCaption"]
        
# Create Chart
chart = milestone_chart(seriesList.values())
#If necessary, define custom time interval here:
#chart.current_time_interval = time_interval_enum.quarters
# Set Chart title from specified DataField
chart.chart_title=df.DataArea.Customizing.ChildrenDFC.TryGetValue(chartTitleField)[1].Title 
# Finally render chart do client-control
ctl = chart.get_element_host()| Member | Type | Comment | |
|---|---|---|---|
 time_interval  | 
 Enum of type  time_interval_enum   | 
 Sets the time interval for label distance and chart grid. This property is set to _time_interval_enum.automatic by default, but can be overvritten with any value of the specified enumeration. In case of time_interval_enum.automatic, the time interval is dynamically choosen according to chart dimensions and data.  | 
|
 current_data_series  | 
 List of chart data series. Data series must be provided as instances of type milestone_dataseries.  | 
If chart rendering is started without this property set up, an exception will be thrown. | |
 chart_title  | 
Specifies the string used as chart title | If no chart title is set up, a hard coded, unlocalized string will be used: "Meilenstein-Trendanalyse" | |
| Method | Parameters | Return value | Comment | 
|---|---|---|---|
 milestone_chart (dataSeries) (constructor)  | 
 Optional: List of chart data series. Data series must be provided as instances of type milestone_dataseries.  | 
Returns a new instance of milestone_chart. | If source data is not specified in the constructor parameter, it has to be assigned to the current_data_series property later. | 
 get_element_host()  | 
  none  | 
Returns the configured chart object wrapped up in an instance of ElementHost | ElementHost is a wrapper-class that enables the use of WPF-Controls inside WinForms-Applications. As the supplied chart is such a WPF-Control, the call of this method is a needed when using the chart in combination with WinForms. | 
 get_chart_grid()  | 
none | Returns the configured chart object wrapped up in an instance of Grid (a WPF-UI-Control) |  When using the chart within a WPF-Form, this method can be called instead of using the wrapper method get_element_host(). As the chart is native WPF-Control there is no need for a wrapper-control in case of WPF-Appliances.  | 
| Member | Type | Comment | |
|---|---|---|---|
| data_points |  A dictionary containing the DateTime-Pairs representing the source data for the milestone chart.  Both X (report date) and Y (estimated finish date) milestone values have to be assigned as DateTime-objects.  | 
In order to use the data series with milestone_chart, at least the DataPoints property has to be set up after creating the instance. | |
| title | Optional. Specifiy a fixed caption for this data series. | By default, series title is optained from source data (DataField 08636, Process Caption) | |
| color | Optional. Specifiy a fixed color for all data points of this series. | By default, color of data points is choosen automatically for each series. | |
| Method | Parameters | Return value | Comment | 
|---|---|---|---|
 milestone_dataseries()  | 
none | Returns a new instance of milestone_dataseries |  In order to use the data series with milestone_chart, at least the data_points property has to be set up after creating the instance. See property data_points for further information.  | 
<Grid
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:vc="clr-namespace:Visifire.Charts;assembly=WPFVisifire.Charts"
x:Name="LayoutRoot"
        <vc:Chart Watermark="False"> </Grid>
 Klasse: Charthelper __init__(): Konstruktor  get_chart_dict().
get_chart_dict: void  df_reference, festgelegt wurden.  PPMS_Chart_generator Klasse weitergeleitet werden kann.
get_di_title: String  
 Klasse: PPMS_chart_generator PPMS_chart_generator
xaml_chart: Type String(XML)
xaml_dataseries: Type String (XML)  xaml_colorset: Type String(XML)  xaml_background_brush: Type String(XML)  dict_values: Type Dictionary (Hash Table)  __init__(): Konstruktor  create_element_host():  set_values():  
 UML-Diagramm aller verwendeten Klassen:
| Member | Type | Comment | |
|---|---|---|---|
| df | DataField | The DataField -Object containing the current Python-Script | |
| df_reference | Dictionary | The Dictionary matching the Chart-Parameters with their DataField -equivalents | |
| da_id | String | The DataArea where raw data is obtained from | |
| Method | Parameters | Return value | Comment | 
| Charthelper(df: DataField , df_reference: Dictionary, da_id: DataArea ) |  df, DataField The DataField -Object containing the current Python-Script  df_reference, Dictionary   da_id, String   | 
see comment | Initializes the Charthelper-Instance with default values and then calls get_chart_dict(). | 
| get_chart_dict() | none | Writes processed values into value_dict |  Prepares the given raw data for use with PPMS_chart_generator.  The processing applied to the data depends on the parameters found in df_reference  | 
| get_di_title(Uid: String) |  Uid, String Uid of the desired DataField  | 
Returns a String containing the title of the DataField with the specified UID. | |
| Method | Parameters | Return value | Comment | 
|---|---|---|---|
| PPMS_chart_generator(xaml_chart: String, xaml_colorset="": String, xaml_background_brush="": String, dict_values={}: Dictionary, AxesX _label="": String, AxesY _label="":String, Title="": int) |  xaml_chart, String XAML-Code used as basic Chart-Template xaml_dataseries, String XAML-Code that detemines the Chart-type (e.g. bars, pie) xaml_colorset, String XAML-Code used for formating of data-series xaml_background_brush, String XAML-Code used for formating of chart background dict_values, Dictionary Contains the prepared data used for chart generation QAxesX_label, String Caption of the X-Axis QAxesY_label, String Caption of the Y-Axis  | 
After execution, class-member winpanel contains a Chart-Control ready for usage | The produced control can be used within Windows Forms appliances | 
| create_element_host() | none | Assigns a new instance of ElementHost (containing generated Chart) to class-member winpanel | To reflect changes of properties, the chart needs to be redrawn via draw_chart() and then embedded into an ElementHost via create_element_host() | 
| draw_chart() | none | String containing the XAML-rendering code for current chart. | see also: create_element_host() | 
xaml_chart="""<Grid
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
            xmlns:vc="clr-namespace:Visifire.Charts;assembly=WPFVisifire.Charts"
        <x:Name="LayoutRoot">
            <vc:Chart Watermark="False">
                <vc:Chart.Titles>
                    <vc:Title Text="" />
                </vc:Chart.Titles>
                <vc:Chart.AxesX>
                    <vc:Axis Title="" />
                </vc:Chart.AxesX>
                <vc:Chart.AxesY>
                    <vc:Axis Title="" />
                </vc:Chart.AxesY>
            <vc:Chart>
        <Grid>"""
xaml_dataseries="""<UserControl
            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                xmlns:vc="clr-namespace:Visifire.Charts;
                               <assembly=WPFVisifire.Charts">
             <vc:Chart>
                <vc:Chart.Series>
                    vc:DataSeries RenderAs="Pie" MarkerEnabled="True"
                           <MarkerType="Circle" LegendText="">
                </vc:Chart.Series>
            </vc:Chart>
        </UserControl>"""
xaml_colorset=""
xaml_background_brush=""
"""Define Chart - Properties"""
da_id='42162'
#Set datafield_id for chart_values
df_reference={}
df_reference["AxisXLabel"]="134082"
df_reference["LegendText"]=""
df_reference["XValue"]=""
df_reference["YValue"]="142717"
df_reference["ZValue"]=""
df_reference["AxisYLabel"]= df_reference["YValue"]
title=df.Dataarea.Customizing.Name
###Automatically generated### ###Changes will be overwritten### from charthelper import Charthelper from chart_generator import PPMS_chart_generator #Execute datafield configuration exec(df.Customizing.PythonScriptSettings) #Get charthelper object ch = Charthelper(df, df_reference, da_id) #Get value dictionary value_dict = ch.value_dict """Create PPMS_chart_generator instance para.1 - xaml_chart, no default value para.2 - xaml_dataseries, no default value para.3 - xaml_colorset, no default value para.4 - xaml_background_brush, no default value para.5 - dict_values: dictionary, default empty dictionary para.6 - AxesX _label: String, default empty para.7 - AxesY _label: String, default empty para.8 - Title: String, default --> AxesX _label + "/" + AxesY _labell """ #Create PPMS Chart chart_panel = PPMS_chart_generator(xaml_chart, xaml_dataseries, xaml_colorset, xaml_background_brush, dict_values=ch.value_dict, AxesX _label=ch.get_di_title(df_reference["AxisXLabel"]), AxesY _label=ch.get_di_title(df_reference["AxisYLabel"]), Title=title) #Get PMS Chart panel ctl = chart_panel.winpanel #Delete datafield variables del xaml_chart del xaml_dataseries del da_id del df_reference del title del ch del value_dict del chart_panel del Charthelper del PPMS_chart_generator del xaml_background_brush del xaml_colorset
| I | Attachment | History |  Size | 
Date | Comment | 
|---|---|---|---|---|---|
|   | 
Charts.doc | r1 | 832.0 K | 2009-10-13 - 11:05 | |
|   | 
Chart5.png | r2 r1 | 52.5 K | 2009-10-13 - 14:06 | |
|   | 
XAMLTemplates.png | r2 r1 | 46.2 K | 2009-10-13 - 11:26 | |
|   | 
Chart9.png | r4 r3 r2 r1 | 39.1 K | 2009-10-13 - 14:16 | |
|   | 
Chart4.png | r1 | 10.0 K | 2009-09-24 - 13:52 | |
|   | 
Chart1.png | r1 | 6.8 K | 2009-09-24 - 13:34 | |
|   | 
Chart2.png | r1 | 5.8 K | 2009-09-24 - 13:41 | |
|   | 
Chart8.png | r2 r1 | 5.4 K | 2009-10-13 - 14:14 | |
|   | 
Chart6.png | r2 r1 | 4.0 K | 2009-10-13 - 14:10 | |
|   | 
Chart7.png | r2 r1 | 3.7 K | 2009-10-13 - 14:12 | |
|   | 
Chart3.png | r1 | 3.0 K | 2009-09-24 - 13:44 |