Problem in Line chart to give different palatte for lines

2 posts, 0 answers
  1. Jake
    Jake avatar
    8 posts
    Member since:
    Aug 2014

    Posted 15 Sep 2014 Link to this post

    Hi Team,

    i m working on line chart series and i gave custom palette for line but its not applying , can some body help for it !
    please . here what i m trying from your example only


    public RadCartesianChartView lineChartView() {

            try {

                initData();

                linechartView = new RadCartesianChartView(this);
                LineSeries lineSeries = new LineSeries(this);

                lineSeries.setCategoryBinding(new DataPointBinding() {
                    @Override
                    public Object getValue(Object o) {
                        return ((MonthResults) o).getMonth();
                    }
                });
                lineSeries.setValueBinding(new DataPointBinding() {
                    @Override
                    public Object getValue(Object o) {
                        return ((MonthResults) o).getResult();
                    }
                });
                lineSeries.setData(this.monthResults);

                // lineSeries.setStrokeColor(Color.RED);

                ChartPalette customPalette = new ChartPalette();
                PaletteEntryCollection collection = new PaletteEntryCollection();

                collection.setFamily(lineSeries.paletteFamily());
                PaletteEntry entry = new PaletteEntry(Color.RED);
                collection.add(entry);
                customPalette.seriesEntries().add(collection);
                linechartView.setPalette(customPalette);
                linechartView.setSelectionPalette(customPalette);
                linechartView.getSeries().add(lineSeries);

                CategoricalAxis horizontalAxis = new CategoricalAxis(this);
                linechartView.setHorizontalAxis(horizontalAxis);

                LinearAxis verticalAxis = new LinearAxis(this);
                linechartView.setVerticalAxis(verticalAxis);

                ChartPanAndZoomBehavior behavior = new ChartPanAndZoomBehavior();

                behavior.setZoomMode(ChartPanZoomMode.VERTICAL);
                behavior.setPanMode(ChartPanZoomMode.BOTH);
                linechartView.getBehaviors().add(behavior);
                linechartView.getBehaviors().add(new ChartSelectionBehavior());

            } catch (Exception e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            return linechartView;

        }



    initdata Function

    private void initData() {

            monthResults = new ArrayList<MonthResults>();
            monthResults.add(new MonthResults("Jan", 25, 10));
            monthResults.add(new MonthResults("Feb", 30, 10));
            monthResults.add(new MonthResults("Mar", 40, 20));

            // monthResults.add(new MonthResults("Mar", 15));
            // monthResults.add(new MonthResults("Apr", 17));
            // monthResults.add(new MonthResults("May", 21));
            // monthResults.add(new MonthResults("Jun", 28));
            // monthResults.add(new MonthResults("Jul", 32));
            // monthResults.add(new MonthResults("Aug", 48));
            // monthResults.add(new MonthResults("Sep", 51));
            // monthResults.add(new MonthResults("Oct", 42));
            // monthResults.add(new MonthResults("Nov", 57));
            // monthResults.add(new MonthResults("Dec", 60));

        }

  2. Victor
    Admin
    Victor avatar
    1351 posts

    Posted 18 Sep 2014 Link to this post

    Hi Jake,

    Thanks for the question.
    Why don't you simply clone the existing palette and tweak it? It's easier. Take a look at the example below:
    RadCartesianChartView chartView = new RadCartesianChartView(this);
    ChartPalette customPalette = chartView.getPalette().clone();
    PaletteEntry entry = customPalette.getEntry(ChartPalette.LINE_FAMILY, 0);
    entry.setStroke(Color.RED);
    entry.setStrokeWidth(10);
    chartView.setPalette(customPalette);


    Regards,
    Victor
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  3. DevCraft banner
Back to Top