ASE Home Page Products Download Purchase Support About ASE
ChartDirector Support
Forum HomeForum Home   SearchSearch

Message ListMessage List     Post MessagePost Message

  New idea?
Posted by Frank on Nov-28-2015 22:50
Hi Peter,

in my practice i like show deviation of dimension measuring over a time axis in a chart. My first idea was using of an surface chart. But a surface chart interpolate color in x and y direction. A workaround is using of scatter chart without 3rd dimension, grouping deviations and use squares for show. Issue here is to find right size of squares for long series of measure.
Is it possible to create a chart like surface chart that interpolate color only in one direction. The result is like column or bar chart.

Best regards
Frank

  Re: New idea?
Posted by Peter Kwan on Dec-01-2015 01:22
Attachments:
Hi Frank,

Do you have an example chart to help me understand your idea?

In ChartDirector, there are several sample code that shows how to draw "bands" around
data points. An example is the "Line with Error Symbols" sample code. Two other sample
code are "Confidence Bands" and "Line Comparison". The bands are just numbers and can
mean anything. For example, you can use "deviation" as the numbers to plot the bands. You
can also add multiple bands to the chart.

I have attached 3 images for your reference. The first one is from the "Line with Error
Symbols". The other two are not in the sample code. One of them is drawn using a box-
whisker layer and a scatter layer. The other is drawn using a line layer with two
InterLineLayers.

Regards
Peter Kwan
errline.png
boxwhisker_scatter.png
bands.png

  Re: New idea?
Posted by Frank on Dec-01-2015 02:24
Attachments:
Hi Peter,

in attachment you find an example. The x-axis are the measure points. As chart I use a Scatter Chart.
I have define 5 groups: ALL < -1%, -1% <= OLL < -.5%, -.5% <= OK <= .5%, .5% < OLH <= 1% and 1% < ALH. So I have normal Deviation for each measure point for different set values and different limits.

    cALH = 0xff2255
    cOLH = 0xcccc00
    c_OK = 0x00eeaa
    cOLL = 0x0099bb
    cALL = 0x3300ee

    body = Container()

    divMP = Div(style="float:left;")

    divMP.append(Div(Image(src="/WZKarte/wsgi/wzImage.py?A0020=%d" % A0020, style="border:none;"), style="text-align:center;"))

    xdataALH = []
    xdataOLH = []
    xdata_OK = []
    xdataOLL = []
    xdataALL = []
    ydataALH = []
    ydataOLH = []
    ydata_OK = []
    ydataOLL = []
    ydataALL = []
    zdataALH = []
    zdataOLH = []
    zdata_OK = []
    zdataOLL = []
    zdataALL = []
    yLabel   = ['',]

    lastStrang = 1
    i = 1
    for (PRUEFNR, DATUM, km_Stand, Strang,
         ABW201,ABW202,ABW203,ABW204,ABW205,ABW206,ABW207,ABW208,ABW209,ABW210,
         ABW211,ABW212,ABW213,ABW214,ABW215,ABW216,ABW217,ABW218,ABW219,ABW220,
         ABW221,ABW222,ABW223,ABW224,ABW225,ABW226,ABW227,ABW228,ABW229,ABW230,
         ABW231,ABW232,ABW233,ABW234,ABW235,ABW236,ABW237,ABW238,ABW239) in recSet:
        if (Strang != lastStrang):
            yLabel.append('')
            i += 1

            c = pychartdir.ThreeDScatterChart(720, max(600, 200 +(i *35)))

            c.setPlotRegion(335, max(600, 170 +(i *35)) /2, 580, max(600, (i *35)), 0)

            title = c.addTitle(u"%s<*br*>%s %d" % (LangText(u"Abweichungen der Me?punkte", typ="pdf"),LangText(u"Strang", typ="pdf"),lastStrang))

            c.setWallVisibility(1,0,0)

            c.setViewAngle(90, 0)

            c.xAxis().setLinearScale(0, 40, 1)
            c.xAxis().setLabels([(("%d" % i) if (i not in (0,40)) else '') for i in xrange(41)])
            c.xAxis().setLabelGap(15)
            c.xAxis().setTitle(u"%s" % LangText(u"Me?punkte", typ="pdf"), "arialbi.ttf", 12)

            c.yAxis().setLabels(yLabel)
            c.yAxis().setLabelOffset(-0.5)
            c.yAxis().setLabelGap(8)

            c.addScatterGroup(xdataALH, ydataALH, zdataALH, "ALH", pychartdir.SquareShape, 12, cALH, cALH)
            c.addScatterGroup(xdataOLH, ydataOLH, zdataOLH, "OLH", pychartdir.SquareShape, 12, cOLH, cOLH)
            c.addScatterGroup(xdata_OK, ydata_OK, zdata_OK, "OK",  pychartdir.SquareShape, 12, c_OK, c_OK)
            c.addScatterGroup(xdataOLL, ydataOLL, zdataOLL, "OLL", pychartdir.SquareShape, 12, cOLL, cOLL)
            c.addScatterGroup(xdataALL, ydataALL, zdataALL, "ALL", pychartdir.SquareShape, 12, cALL, cALL)

            c.addLegend(160, 40, 0)

            divMP.append(Div(Image(src="data:image/png;base64,%s" % c.makeChart2(pychartdir.PNG).encode("base64")), Class="chart"))

            xdataALH = []
            xdataOLH = []
            xdata_OK = []
            xdataOLL = []
            xdataALL = []
            ydataALH = []
            ydataOLH = []
            ydata_OK = []
            ydataOLL = []
            ydataALL = []
            zdataALH = []
            zdataOLH = []
            zdata_OK = []
            zdataOLL = []
            zdataALL = []
            yLabel   = ['',]

            i = 1

        for (x,value) in enumerate((ABW201,ABW202,ABW203,ABW204,ABW205,ABW206,ABW207,ABW208,ABW209,ABW210,
                                    ABW211,ABW212,ABW213,ABW214,ABW215,ABW216,ABW217,ABW218,ABW219,ABW220,
                                    ABW221,ABW222,ABW223,ABW224,ABW225,ABW226,ABW227,ABW228,ABW229,ABW230,
                                    ABW231,ABW232,ABW233,ABW234,ABW235,ABW236,ABW237,ABW238,ABW239),1):
            if (value is None):
                continue

            if   (value > 1.0):     # ALH
                xdataALH.append(x)
                ydataALH.append(i)
                zdataALH.append(value)
            elif (value > 0.5):     # OLH
                xdataOLH.append(x)
                ydataOLH.append(i)
                zdataOLH.append(value)
            elif (value < -1.0):    # ALL
                xdataALL.append(x)
                ydataALL.append(i)
                zdataALL.append(value)
            elif (value < -0.5):    # OLL
                xdataOLL.append(x)
                ydataOLL.append(i)
                zdataOLL.append(value)
            else:                   # OK
                xdata_OK.append(x)
                ydata_OK.append(i)
                zdata_OK.append(value)

        label = "%d<*br*>%s" % (PRUEFNR,DATUM.strftime(_strfdate))
        if km_Stand:
            label += "<*br*>%.3f %s" % (km_Stand,LangText(u"km"))
        yLabel.append(label)

        lastStrang = Strang
        i += 1

    yLabel.append('')
    i += 1

    c = pychartdir.ThreeDScatterChart(720, max(600, 200 +(i *35)))

    c.setPlotRegion(335, max(600, 170 +(i *35)) /2, 580, max(600, (i *35)), 0)

    title = c.addTitle((u"%s" % LangText(u"Abweichungen der Me?punkte", typ="pdf")) if (STRAENGE == 1) else (u"%s<*br*>%s %d" % (LangText(u"Abweichungen der Me?punkte", typ="pdf"),LangText(u"Strang", typ="pdf"),lastStrang)))

    c.setWallVisibility(1,0,0)

    c.setViewAngle(90, 0)

    c.xAxis().setLinearScale(0, 40, 1)
    c.xAxis().setLabels([(("%d" % i) if (i not in (0,40)) else '') for i in xrange(41)])
    c.xAxis().setLabelGap(15)
    c.xAxis().setTitle(u"%s" % LangText(u"Me?punkte", typ="pdf"), "arialbi.ttf", 12)

    c.yAxis().setLabels(yLabel)
    c.yAxis().setLabelOffset(-0.5)
    c.yAxis().setLabelGap(8)

    c.addScatterGroup(xdataALH, ydataALH, zdataALH, "ALH", pychartdir.SquareShape, 12, cALH, cALH)
    c.addScatterGroup(xdataOLH, ydataOLH, zdataOLH, "OLH", pychartdir.SquareShape, 12, cOLH, cOLH)
    c.addScatterGroup(xdata_OK, ydata_OK, zdata_OK, "OK",  pychartdir.SquareShape, 12, c_OK, c_OK)
    c.addScatterGroup(xdataOLL, ydataOLL, zdataOLL, "OLL", pychartdir.SquareShape, 12, cOLL, cOLL)
    c.addScatterGroup(xdataALL, ydataALL, zdataALL, "ALL", pychartdir.SquareShape, 12, cALL, cALL)

    c.addLegend(160, 40, 0)

    divMP.append(Div(Image(src="data:image/png;base64,%s" % c.makeChart2(pychartdir.PNG).encode("base64")), Class="chart"))


This is code fragment for chart generation.

Greeting
Frank
example_band_contour.png

  Re: New idea?
Posted by Peter Kwan on Dec-02-2015 03:32
Hi Frank,

Thanks for the example. It helps me to understand the issue much more clearly.

I am originally thinking the "deviation" is the deviation in the y-direction. Now I see that the deviation is in fact in a third dimension. It reminds me of a "wafer" chart. See:

http://www.chartdir.com/forum/download_thread.php?bn=chartdir_support&thread=1340610047#N1340657839

For your case, if the third dimension can be represented as colors, I think using scatter layers like what you are doing now is the best method. It is clear and easy to read, and it can also support tooltips and hot spots for the symbols.

You can consider to use XYChart with 2D scatter layers instead of 3D scatter charts. For the symbol size, with XYChart, it is:

#the x-axis scale is 0 to 40, and we leave 20% gap between symbols
symbolSize = c.getPlotArea().getWidth() / 40 * 0.8

Instead of pixel unit, you can also express the symbol size as 0.8 x-axis units using LineLayer.setSymbolScale.

As an alternative to using scatter layers, you can also consider to use a small line chart fluctuation around the horizontal grid line for the deviation, or you can use both the current scatter layers and put a line layer on top of the symbols.

Regards
Peter Kwan