Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
545
composite chart
posted

I have just build a composite chart with two layers, one for the ColumnChart and one for the LineChart to wich belongs two series.

The idea is to plot, for each day in the period selected, the actual value display in columns compared to a copule of goals displayed in LineChart.

The y_axis is common between LineChart layer and ColumnChart layer, but not the x_axis, because changes the DataType property (AxisDataType.Time for the lineChart, AxisDataType.String for the columnChart).

The problem now is to display correctly x_axis labels: if I try to display on the x_axis associated to the columnChart, the ItemFormatString can't be formatted as date. Otherwise if I display labels on the x_axis associated to lineChart, the labels are referenced to the line points that are not aligned with column (I don't understand why).

The second problem is to change the layout of the borders of each single column in Column chart: I would like to set a different color from the fill color and a different line thickness. To set up the fill color I have changed the PaintElement directly on the columns series (through PEs.Add function).

 

Thanks in advance!

 

 

  • 26458
    Offline posted

    The line and column points don't usually align due to the way line charts are rendered. Line charts start and end at the edge of the chart area, unline column charts, where a point is the center of the column. You can adjust the x axis margins to push the line inside the chart area more.

    xAxis.Margin.Near.MarginType = LocationType.Percentage;
    xAxis.Margin.Near.Value = 4;
    xAxis.Margin.Far.MarginType = LocationType.Percentage;
    xAxis.Margin.Far.Value = 4;

    You'll have to make the Value adjustment based on the number of data points and the chart's size.

    Setting borders can be done with PaintElement.Stroke and PaintElement.StrokeWidth property. You can do this in the same place you're adding PEs to the series. Just set Stroke, StrokeWidth properties along with Fill.