Exemple #1
0
        public VerticalChartLabelsModule()
        {
            Get["/examples/charts/vertical-bar-charts/vertical-chart-labels/multi-line-group-labels"] = _ =>
            {
                var svg = new Svg(400, 200);

                var chart = svg.VerticalBarChart(DataSources.GetIndustriesData())
                            .WithDataLabelFormat("{0}%")
                            .ShowDataLabelOutsideItem()
                            .WithPointColorGenerator(new StackBasedDataPointColorGenerator(new[]
                {
                    "#6666ff",
                    "orange"
                }))
                            .WithStroke("black")
                            .WithStrokeWidth(2)
                            .WithPadding(10)
                            .WithGroupLabelAutoLineSplit(8);

                return(Response.AsSvg(svg));
            };
        }
        public VerticalChartLabelsModule()
        {
            Get["/examples/charts/vertical-bar-charts/vertical-chart-labels/multi-line-group-labels"] = _ =>
            {
                var svg = new Svg(400, 200);

                var chart = svg.VerticalBarChart(DataSources.GetIndustriesData())
                    .WithDataLabelFormat("{0}%")
                    .ShowDataLabelOutsideItem()
                    .WithPointColorGenerator(new StackBasedDataPointColorGenerator(new[]
                    {
                        "#6666ff",
                        "orange"
                    }))
                    .WithStroke("black")
                    .WithStrokeWidth(2)
                    .WithPadding(10)
                    .WithGroupLabelAutoLineSplit(8);

                return Response.AsSvg(svg);
            };
        }
Exemple #3
0
        public SimpleChartsModule()
        {
            Get["/examples/charts/vertical-bar-charts/simple-charts/1"] = _ =>
            {
                var svg = new Svg(200, 150);

                var data = new BarChartData(new double[]
                {
                    50, 25, 5
                });
                var chart = svg.VerticalBarChart(data)
                    .WithDataLabelFormat("{0}%")
                    .ShowDataLabelOutsideItem();

                return Response.AsSvg(svg);
            };

            Get["/examples/charts/vertical-bar-charts/simple-charts/2"] = _ =>
            {
                var svg = new Svg();

                var data = new BarChartData(new[]
                {
                    new BarChartGroupData(new[]
                    {
                        new BarChartStackData(new double[] {36, 35, 12}),
                        new BarChartStackData(new double[] {29, 4, 35}),
                        new BarChartStackData(new double[] {19, 11})
                    }),
                    new BarChartGroupData(new[]
                    {
                        new BarChartStackData(new double[] {18}),
                        new BarChartStackData(new double[] {8, 31, 22}),
                        new BarChartStackData(new double[] {2, 4, 28}),
                    }),
                    new BarChartGroupData(new[]
                    {
                        new BarChartStackData(new double[] {21, 13, 36}),
                        new BarChartStackData(new double[] {19, 9}),
                        new BarChartStackData(new double[] {34}),
                    }),
                });
                var chart = svg.VerticalBarChart(data);

                return Response.AsSvg(svg);
            };

            Get["/examples/charts/vertical-bar-charts/simple-charts/3"] = _ =>
            {
                var svg = new Svg();

                var data = new BarChartData(new[]
                {
                    new BarChartGroupData(new[]
                    {
                        new BarChartStackData(new double[] {36, 35, 12}, "Stack 1"),
                        new BarChartStackData(new double[] {29, 4, 35}, "Stack 2"),
                        new BarChartStackData(new double[] {19, 11}, "Stack 3")
                    }, "Group 1"),
                    new BarChartGroupData(new[]
                    {
                        new BarChartStackData(new double[] {18}, "Stack 4"),
                        new BarChartStackData(new double[] {8, 31, 22}, "Stack 5"),
                        new BarChartStackData(new double[] {2, 4, 28}, "Stack 6"),
                    }, "Group 2"),
                    new BarChartGroupData(new[]
                    {
                        new BarChartStackData(new double[] {21, 13, 36}, "Stack 7"),
                        new BarChartStackData(new double[] {19, 9}, "Stack 8"),
                        new BarChartStackData(new double[] {34}, "Stack 9"),
                    }, "Group 3"),
                });
                var chart = svg.VerticalBarChart(data)
                    .WithDataLabelFormat("{0}%");

                return Response.AsSvg(svg);
            };

            Get["/examples/charts/vertical-bar-charts/simple-charts/4"] = _ =>
            {
                var svg = new Svg();

                var data = new BarChartData(new double[]
                {
                    50, 25, 5
                });
                var chart = svg.VerticalBarChart(data)
                    .WithDataLabelFormat("{0}%")
                    .ShowDataLabelOutsideItem()
                    .WithGutter(40)
                    .WithFill("#dddddd")
                    .WithPadding(40)
                    .WithDrawableFill("#cccccc")
                    .WithStroke("black")
                    .WithStrokeWidth(2);

                return Response.AsSvg(svg);
            };

            Get["/examples/charts/vertical-bar-charts/simple-charts/stack-based-color-generator"] = _ =>
            {
                var svg = new Svg(600, 200);

                var chart = svg.VerticalBarChart(DataSources.GetIndustriesData())
                    .WithDataLabelFormat("{0}%")
                    .ShowDataLabelOutsideItem()
                    .WithPointColorGenerator(new StackBasedDataPointColorGenerator(new[]
                    {
                        "#6666ff",
                        "orange"
                    }))
                    .WithStroke("black")
                    .WithStrokeWidth(2)
                    .WithPadding(10);

                return Response.AsSvg(svg);
            };

            Get["/examples/charts/vertical-bar-charts/simple-charts/always-show-labels-above-data-points"] = _ =>
            {
                var svg = new Svg(600, 200);

                var chart = svg.VerticalBarChart(DataSources.GetIndustriesData())
                    .WithDataLabelFormat("{0}%")
                    .AlwaysShowDataLabel()
                    .WithPointColorGenerator(new StackBasedDataPointColorGenerator(new[]
                    {
                        "#6666ff",
                        "orange"
                    }))
                    .WithStroke("black")
                    .WithStrokeWidth(2)
                    .WithPadding(10);

                return Response.AsSvg(svg);
            };

            Get["/examples/charts/vertical-bar-charts/simple-charts/7"] = _ =>
            {
                var svg = new Svg();

                var data = new BarChartData(new[]
                {
                    new BarChartGroupData(new[]
                    {
                        new BarChartStackData(new double[] {36, 35, 12}, "Stack 1"),
                        new BarChartStackData(new double[] {29, 4, 35}, "Stack 2"),
                        new BarChartStackData(new double[] {19, 11}, "Stack 3")
                    }, "Group 1"),
                    new BarChartGroupData(new[]
                    {
                        new BarChartStackData(new double[] {18}, "Stack 4"),
                        new BarChartStackData(new double[] {8, 31, 22}, "Stack 5"),
                        new BarChartStackData(new double[] {2, 4, 28}, "Stack 6"),
                    }, "Group 2"),
                    new BarChartGroupData(new[]
                    {
                        new BarChartStackData(new double[] {21, 13, 36}, "Stack 7"),
                        new BarChartStackData(new double[] {19, 9}, "Stack 8"),
                        new BarChartStackData(new double[] {34}, "Stack 9"),
                    }, "Group 3"),
                });
                var chart = svg.VerticalBarChart(data)
                    .WithDataLabelFormat("{0}%")
                    .WithPointColorGenerator(new PointBasedDataPointColorGenerator(new[]
                    {
                        "#617073",
                        "#7A93AC",
                        "#92BCEA",
                        "#AFB3F7"
                    }));

                return Response.AsSvg(svg);
            };

            Get["/examples/charts/vertical-bar-charts/simple-charts/8"] = _ =>
            {
                var svg = new Svg();

                var data = new BarChartData(new[]
                {
                    new BarChartGroupData(new[]
                    {
                        new BarChartStackData(new double[] {36, 35, 12}, "Stack 1"),
                        new BarChartStackData(new double[] {29, 4, 35}, "Stack 2"),
                        new BarChartStackData(new double[] {19, 11}, "Stack 3")
                    }, "Group 1"),
                    new BarChartGroupData(new[]
                    {
                        new BarChartStackData(new double[] {18}, "Stack 4"),
                        new BarChartStackData(new double[] {8, 31, 22}, "Stack 5"),
                        new BarChartStackData(new double[] {2, 4, 28}, "Stack 6"),
                    }, "Group 2"),
                    new BarChartGroupData(new[]
                    {
                        new BarChartStackData(new double[] {21, 13, 36}, "Stack 7"),
                        new BarChartStackData(new double[] {19, 9}, "Stack 8"),
                        new BarChartStackData(new double[] {34}, "Stack 9"),
                    }, "Group 3"),
                });
                var chart = svg.VerticalBarChart(data)
                    .WithDataLabelFormat("{0}%")
                    .WithPointColorGenerator(new PointBasedDataPointColorGenerator(new[]
                    {
                        "#171A21",
                        "#617073",
                        "#7A93AC",
                        "#92BCEA",
                        "#AFB3F7"
                    }))
                    .WithPointLabelColorGenerator(new PointBasedDataPointColorGenerator(new[]
                    {
                        "#fff",
                        "#fff",
                        "#000",
                        "#000",
                        "#000",
                    }));

                return Response.AsSvg(svg);
            };

            Get["/examples/charts/vertical-bar-charts/simple-charts/labels-on-data-points-auto-split"] = _ =>
            {
                var svg = new Svg(600, 200);

                svg.VerticalBarChart(DataSources.GetRenewableEnergyData())
                    .WithDataPointAutoLineSplit(12)
                    .WithDataLabelFormat("{0:p}")
                    .AlwaysShowDataLabel();

                return Response.AsSvg(svg);
            };

            Get["/examples/charts/vertical-bar-charts/simple-charts/as-inline-svg"] = _ =>
            {
                var svg = new Svg(200, 150);

                var data = new BarChartData(new double[]
                {
                    50, 25, 5
                });
                var chart = svg.VerticalBarChart(data)
                    .WithDataLabelFormat("{0}%")
                    .ShowDataLabelOutsideItem();

                return Response.AsText(svg.ToInlineSvgString());
            };
        }
Exemple #4
0
        public SimpleChartsModule()
        {
            Get["/examples/charts/vertical-bar-charts/simple-charts/1"] = _ =>
            {
                var svg = new Svg(200, 150);

                var data = new BarChartData(new double[]
                {
                    50, 25, 5
                });
                var chart = svg.VerticalBarChart(data)
                            .WithDataLabelFormat("{0}%")
                            .ShowDataLabelOutsideItem();

                return(Response.AsSvg(svg));
            };

            Get["/examples/charts/vertical-bar-charts/simple-charts/2"] = _ =>
            {
                var svg = new Svg();

                var data = new BarChartData(new[]
                {
                    new BarChartGroupData(new[]
                    {
                        new BarChartStackData(new double[] { 36, 35, 12 }),
                        new BarChartStackData(new double[] { 29, 4, 35 }),
                        new BarChartStackData(new double[] { 19, 11 })
                    }),
                    new BarChartGroupData(new[]
                    {
                        new BarChartStackData(new double[] { 18 }),
                        new BarChartStackData(new double[] { 8, 31, 22 }),
                        new BarChartStackData(new double[] { 2, 4, 28 }),
                    }),
                    new BarChartGroupData(new[]
                    {
                        new BarChartStackData(new double[] { 21, 13, 36 }),
                        new BarChartStackData(new double[] { 19, 9 }),
                        new BarChartStackData(new double[] { 34 }),
                    }),
                });
                var chart = svg.VerticalBarChart(data);

                return(Response.AsSvg(svg));
            };

            Get["/examples/charts/vertical-bar-charts/simple-charts/3"] = _ =>
            {
                var svg = new Svg();

                var data = new BarChartData(new[]
                {
                    new BarChartGroupData(new[]
                    {
                        new BarChartStackData(new double[] { 36, 35, 12 }, "Stack 1"),
                        new BarChartStackData(new double[] { 29, 4, 35 }, "Stack 2"),
                        new BarChartStackData(new double[] { 19, 11 }, "Stack 3")
                    }, "Group 1"),
                    new BarChartGroupData(new[]
                    {
                        new BarChartStackData(new double[] { 18 }, "Stack 4"),
                        new BarChartStackData(new double[] { 8, 31, 22 }, "Stack 5"),
                        new BarChartStackData(new double[] { 2, 4, 28 }, "Stack 6"),
                    }, "Group 2"),
                    new BarChartGroupData(new[]
                    {
                        new BarChartStackData(new double[] { 21, 13, 36 }, "Stack 7"),
                        new BarChartStackData(new double[] { 19, 9 }, "Stack 8"),
                        new BarChartStackData(new double[] { 34 }, "Stack 9"),
                    }, "Group 3"),
                });
                var chart = svg.VerticalBarChart(data)
                            .WithDataLabelFormat("{0}%");

                return(Response.AsSvg(svg));
            };

            Get["/examples/charts/vertical-bar-charts/simple-charts/4"] = _ =>
            {
                var svg = new Svg();

                var data = new BarChartData(new double[]
                {
                    50, 25, 5
                });
                var chart = svg.VerticalBarChart(data)
                            .WithDataLabelFormat("{0}%")
                            .ShowDataLabelOutsideItem()
                            .WithGutter(40)
                            .WithFill("#dddddd")
                            .WithPadding(40)
                            .WithDrawableFill("#cccccc")
                            .WithStroke("black")
                            .WithStrokeWidth(2);

                return(Response.AsSvg(svg));
            };

            Get["/examples/charts/vertical-bar-charts/simple-charts/stack-based-color-generator"] = _ =>
            {
                var svg = new Svg(600, 200);

                var chart = svg.VerticalBarChart(DataSources.GetIndustriesData())
                            .WithDataLabelFormat("{0}%")
                            .ShowDataLabelOutsideItem()
                            .WithPointColorGenerator(new StackBasedDataPointColorGenerator(new[]
                {
                    "#6666ff",
                    "orange"
                }))
                            .WithStroke("black")
                            .WithStrokeWidth(2)
                            .WithPadding(10);

                return(Response.AsSvg(svg));
            };

            Get["/examples/charts/vertical-bar-charts/simple-charts/always-show-labels-above-data-points"] = _ =>
            {
                var svg = new Svg(600, 200);

                var chart = svg.VerticalBarChart(DataSources.GetIndustriesData())
                            .WithDataLabelFormat("{0}%")
                            .AlwaysShowDataLabel()
                            .WithPointColorGenerator(new StackBasedDataPointColorGenerator(new[]
                {
                    "#6666ff",
                    "orange"
                }))
                            .WithStroke("black")
                            .WithStrokeWidth(2)
                            .WithPadding(10);

                return(Response.AsSvg(svg));
            };

            Get["/examples/charts/vertical-bar-charts/simple-charts/7"] = _ =>
            {
                var svg = new Svg();

                var data = new BarChartData(new[]
                {
                    new BarChartGroupData(new[]
                    {
                        new BarChartStackData(new double[] { 36, 35, 12 }, "Stack 1"),
                        new BarChartStackData(new double[] { 29, 4, 35 }, "Stack 2"),
                        new BarChartStackData(new double[] { 19, 11 }, "Stack 3")
                    }, "Group 1"),
                    new BarChartGroupData(new[]
                    {
                        new BarChartStackData(new double[] { 18 }, "Stack 4"),
                        new BarChartStackData(new double[] { 8, 31, 22 }, "Stack 5"),
                        new BarChartStackData(new double[] { 2, 4, 28 }, "Stack 6"),
                    }, "Group 2"),
                    new BarChartGroupData(new[]
                    {
                        new BarChartStackData(new double[] { 21, 13, 36 }, "Stack 7"),
                        new BarChartStackData(new double[] { 19, 9 }, "Stack 8"),
                        new BarChartStackData(new double[] { 34 }, "Stack 9"),
                    }, "Group 3"),
                });
                var chart = svg.VerticalBarChart(data)
                            .WithDataLabelFormat("{0}%")
                            .WithPointColorGenerator(new PointBasedDataPointColorGenerator(new[]
                {
                    "#617073",
                    "#7A93AC",
                    "#92BCEA",
                    "#AFB3F7"
                }));

                return(Response.AsSvg(svg));
            };

            Get["/examples/charts/vertical-bar-charts/simple-charts/8"] = _ =>
            {
                var svg = new Svg();

                var data = new BarChartData(new[]
                {
                    new BarChartGroupData(new[]
                    {
                        new BarChartStackData(new double[] { 36, 35, 12 }, "Stack 1"),
                        new BarChartStackData(new double[] { 29, 4, 35 }, "Stack 2"),
                        new BarChartStackData(new double[] { 19, 11 }, "Stack 3")
                    }, "Group 1"),
                    new BarChartGroupData(new[]
                    {
                        new BarChartStackData(new double[] { 18 }, "Stack 4"),
                        new BarChartStackData(new double[] { 8, 31, 22 }, "Stack 5"),
                        new BarChartStackData(new double[] { 2, 4, 28 }, "Stack 6"),
                    }, "Group 2"),
                    new BarChartGroupData(new[]
                    {
                        new BarChartStackData(new double[] { 21, 13, 36 }, "Stack 7"),
                        new BarChartStackData(new double[] { 19, 9 }, "Stack 8"),
                        new BarChartStackData(new double[] { 34 }, "Stack 9"),
                    }, "Group 3"),
                });
                var chart = svg.VerticalBarChart(data)
                            .WithDataLabelFormat("{0}%")
                            .WithPointColorGenerator(new PointBasedDataPointColorGenerator(new[]
                {
                    "#171A21",
                    "#617073",
                    "#7A93AC",
                    "#92BCEA",
                    "#AFB3F7"
                }))
                            .WithPointLabelColorGenerator(new PointBasedDataPointColorGenerator(new[]
                {
                    "#fff",
                    "#fff",
                    "#000",
                    "#000",
                    "#000",
                }));

                return(Response.AsSvg(svg));
            };

            Get["/examples/charts/vertical-bar-charts/simple-charts/labels-on-data-points-auto-split"] = _ =>
            {
                var svg = new Svg(600, 200);

                svg.VerticalBarChart(DataSources.GetRenewableEnergyData())
                .WithDataPointAutoLineSplit(12)
                .WithDataLabelFormat("{0:p}")
                .AlwaysShowDataLabel();

                return(Response.AsSvg(svg));
            };

            Get["/examples/charts/vertical-bar-charts/simple-charts/as-inline-svg"] = _ =>
            {
                var svg = new Svg(200, 150);

                var data = new BarChartData(new double[]
                {
                    50, 25, 5
                });
                var chart = svg.VerticalBarChart(data)
                            .WithDataLabelFormat("{0}%")
                            .ShowDataLabelOutsideItem();

                return(Response.AsText(svg.ToInlineSvgString()));
            };
        }
Exemple #5
0
        public GridLegendsModule()
        {
            Get["/examples/charts/grid-legends/standalone-legend"] = _ =>
            {
                var svg = new Svg(400, 3*GridLegend.ItemHeight);

                svg.GridLegend(0, 0)
                    .AddLegendItem(0, 0, "#990000", "Liberal")
                    .AddLegendItem(1, 0, "#000099", "Conservative")
                    .AddLegendItem(0, 1, "#009999", "Bloc Quebecois")
                    .AddLegendItem(1, 1, "#999900", "NDP")
                    .AddLegendItem(2, 0, "#999999", "Other");

                return Response.AsSvg(svg);
            };

            Get["/examples/charts/grid-legends/legend-under-chart"] = _ =>
            {
                var svg = new Svg(400, 400);

                var data = new BarChartData(new double[]
                {
                    133, 98, 54, 19, 4
                });
                var chart = svg.VerticalBarChart(data)
                    .WithDataLabelFormat("{0}")
                    .AlwaysShowDataLabel()
                    .ShowDataLabelOutsideItem()
                    .WithPointColorGenerator(new GroupBasedDataPointColorGenerator(new[]
                    {
                        "#990000", "#000099", "#009999", "#999900", "#999999"
                    }))
                    // bottom gutter for legend
                    .WithBottomGutter(3*GridLegend.ItemHeight + 8);
                chart.GridLegend((chart.X ?? 0) + (chart.Width ?? 0)/2 - GridLegend.ItemWidth, (chart.Y ?? 0) + (chart.Height ?? 0) - 3*GridLegend.ItemHeight + 8)
                    .AddLegendItem(0, 0, "#990000", "Liberal")
                    .AddLegendItem(1, 0, "#000099", "Conservative")
                    .AddLegendItem(0, 1, "#009999", "Bloc Quebecois")
                    .AddLegendItem(1, 1, "#999900", "NDP")
                    .AddLegendItem(2, 0, "#999999", "Other");

                return Response.AsSvg(svg);
            };

            Get["/examples/charts/grid-legends/legend-embedded-in-chart"] = _ =>
            {
                var svg = new Svg(400, 200)
                    .WithBackgroundFill("#eee");

                var data = new BarChartData(new double[]
                {
                    133, 98, 54, 19, 4
                });
                var chart = svg.VerticalBarChart(data)
                    .WithDataLabelFormat("{0}")
                    .AlwaysShowDataLabel()
                    .ShowDataLabelOutsideItem()
                    .WithPointColorGenerator(new GroupBasedDataPointColorGenerator(new[]
                    {
                        "#990000", "#000099", "#009999", "#999900", "#999999"
                    }))
                    .WithGutter(20);
                chart.GridLegend((chart.Width ?? 0) - GridLegend.ItemWidth*2 - 10, 10)
                    .AddLegendItem(0, 0, "#990000", "Liberal")
                    .AddLegendItem(1, 0, "#000099", "Conservative")
                    .AddLegendItem(0, 1, "#009999", "Bloc Quebecois")
                    .AddLegendItem(1, 1, "#999900", "NDP")
                    .AddLegendItem(2, 0, "#999999", "Other");

                return Response.AsSvg(svg);
            };
        }
Exemple #6
0
        public GridLegendsModule()
        {
            Get["/examples/charts/grid-legends/standalone-legend"] = _ =>
            {
                var svg = new Svg(400, 3 * GridLegend.ItemHeight);

                svg.GridLegend(0, 0)
                .AddLegendItem(0, 0, "#990000", "Liberal")
                .AddLegendItem(1, 0, "#000099", "Conservative")
                .AddLegendItem(0, 1, "#009999", "Bloc Quebecois")
                .AddLegendItem(1, 1, "#999900", "NDP")
                .AddLegendItem(2, 0, "#999999", "Other");

                return(Response.AsSvg(svg));
            };

            Get["/examples/charts/grid-legends/legend-under-chart"] = _ =>
            {
                var svg = new Svg(400, 400);

                var data = new BarChartData(new double[]
                {
                    133, 98, 54, 19, 4
                });
                var chart = svg.VerticalBarChart(data)
                            .WithDataLabelFormat("{0}")
                            .AlwaysShowDataLabel()
                            .ShowDataLabelOutsideItem()
                            .WithPointColorGenerator(new GroupBasedDataPointColorGenerator(new[]
                {
                    "#990000", "#000099", "#009999", "#999900", "#999999"
                }))
                            // bottom gutter for legend
                            .WithBottomGutter(3 * GridLegend.ItemHeight + 8);
                chart.GridLegend((chart.X ?? 0) + (chart.Width ?? 0) / 2 - GridLegend.ItemWidth, (chart.Y ?? 0) + (chart.Height ?? 0) - 3 * GridLegend.ItemHeight + 8)
                .AddLegendItem(0, 0, "#990000", "Liberal")
                .AddLegendItem(1, 0, "#000099", "Conservative")
                .AddLegendItem(0, 1, "#009999", "Bloc Quebecois")
                .AddLegendItem(1, 1, "#999900", "NDP")
                .AddLegendItem(2, 0, "#999999", "Other");

                return(Response.AsSvg(svg));
            };

            Get["/examples/charts/grid-legends/legend-embedded-in-chart"] = _ =>
            {
                var svg = new Svg(400, 200)
                          .WithBackgroundFill("#eee");

                var data = new BarChartData(new double[]
                {
                    133, 98, 54, 19, 4
                });
                var chart = svg.VerticalBarChart(data)
                            .WithDataLabelFormat("{0}")
                            .AlwaysShowDataLabel()
                            .ShowDataLabelOutsideItem()
                            .WithPointColorGenerator(new GroupBasedDataPointColorGenerator(new[]
                {
                    "#990000", "#000099", "#009999", "#999900", "#999999"
                }))
                            .WithGutter(20);
                chart.GridLegend((chart.Width ?? 0) - GridLegend.ItemWidth * 2 - 10, 10)
                .AddLegendItem(0, 0, "#990000", "Liberal")
                .AddLegendItem(1, 0, "#000099", "Conservative")
                .AddLegendItem(0, 1, "#009999", "Bloc Quebecois")
                .AddLegendItem(1, 1, "#999900", "NDP")
                .AddLegendItem(2, 0, "#999999", "Other");

                return(Response.AsSvg(svg));
            };
        }